#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

struct Elem
{
  Elem(int val) : val(val), valid(true) {}
  int val;
  bool valid;
};

struct Node
{
  Node(int diff, int val, int idx, Elem* elem) : diff(diff), val(val), idx(idx), elem(elem) {}
  int diff;
  int val;
  int idx;
  Elem* elem;
};

struct NodeCmp
{
  bool operator()(const Node& lhs, const Node& rhs)
  {
    if (lhs.diff == rhs.diff)
      return lhs.val < rhs.val;

    return lhs.diff < rhs.diff;
  }
};

bool IsSorted(const deque<Elem*>& a)
{
  int prev = a[0]->val;
  for (size_t i = 1; i < a.size(); ++i)
  {
    if (!a[i]->valid)
      continue;
    int v = a[i]->val;
    if (a[i]->val < prev)
      return false;
    prev = a[i]->val;
  }
  return true;
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  unordered_set<int> toMove;
  int wrongPlace = 0;
  for (int i = 0; i < num-1; ++i)
  {
    if (order[i] > order[i+1])
    {
      wrongPlace++;
      order[i] = -1;
      toMove.insert(i);
    }
  }

  int gaps = 0;
  {
    //int i = 0;
    int i = 0;
    while (i < num)
    {
      while (i < num && order[i] == -1)
        ++i;

      if (i == num)
        break;

      int start = i;

      ++i;
      while (i < num && order[i] == -1)
        ++i;

      if (i == num)
        break;

      int end = i;

      gaps += (order[end] - order[start]) - 1;
    }
  }

  int res = wrongPlace + gaps;

  printf("%d\n", res);
  return 0;
}


#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <list>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

template <typename T>
void Fill(vector<T>* cont, T val)
{
  for (size_t i = 0; i < cont->size(); ++i)
  {
    (*cont)[i] = val;
  }
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  vector<int> minValues(num);
  int mm = order.back();
  for (int i = num - 1; i >= 0; --i)
  {
    mm = min(order[i], mm);
    minValues[i] = mm;
  }

  vector<int> moved(num+1);
  Fill(&moved, 0);

  int res = 0;
  for (int i = 0; i < num; ++i)
  {
    int cur = order[i];
    if (cur == minValues[i] || moved[cur])
    {
      // sorted
      continue;
    }

    // check cost of moving up to end, vs down to start
    int upCount = 1;
    for (int j = cur + 1; j <= num; ++j)
      upCount += moved[j] ? 0 : 1;

    int downCount = 1;
    for (int j = cur - 1; j > 0; --j)
      downCount += moved[j] ? 0 : 1;

    moved[cur] = 1;
    res += 1;

    if (upCount < downCount)
    {
      for (int j = cur + 1; j <= num; ++j)
      {
        if (!moved[j])
        {
          res += 1;
          moved[j] = 1;
        }
      }
    }
    else
    {
      for (int j = cur - 1; j > 0; --j)
      {
        if (!moved[j])
        {
          res += 1;
          moved[j] = 1;
        }
      }
    }

  }

  printf("%d\n", res);
  return 0;
}


#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

struct Elem
{
  Elem(int val) : val(val), valid(true) {}
  int val;
  bool valid;
};

struct Node
{
  Node(int diff, int val, int idx, Elem* elem) : diff(diff), val(val), idx(idx), elem(elem) {}
  int diff;
  int val;
  int idx;
  Elem* elem;
};

struct NodeCmp
{
  bool operator()(const Node& lhs, const Node& rhs)
  {
    if (lhs.diff == rhs.diff)
      return lhs.val < rhs.val;

    return lhs.diff < rhs.diff;
  }
};

bool IsSorted(const deque<Elem*>& a)
{
  int prev = a[0]->val;
  for (size_t i = 1; i < a.size(); ++i)
  {
    if (!a[i]->valid)
      continue;
    int v = a[i]->val;
    if (a[i]->val < prev)
      return false;
    prev = a[i]->val;
  }
  return true;
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  unordered_set<int> toMove;
  int wrongPlace = 0;
  for (int i = 0; i < num-1; ++i)
  {
    if (order[i] > order[i+1])
    {
      wrongPlace++;
      order[i] = -1;
      toMove.insert(i);
    }
  }

  int gaps = 0;
  {
    //int i = 0;
    int i = 0;
    while (i < num)
    {
      while (i < num && order[i] == -1)
        ++i;

      if (i == num)
        break;

      int start = i;

      ++i;
      while (i < num && order[i] == -1)
        ++i;

      if (i == num)
        break;

      int end = i;

      gaps += (end - start) - 1;
    }
  }

  int res = wrongPlace + gaps;

  printf("%d\n", res);
  return 0;
}


#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <list>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

template <typename T>
void Fill(vector<T>* cont, T val)
{
  for (size_t i = 0; i < cont->size(); ++i)
  {
    (*cont)[i] = val;
  }
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  // find longest increasing subsequence; this is what we keep

  vector<int> placement(num+1);
  for (int i = 0; i < num; ++i)
  {
    int cur = order[i];
    placement[cur] = i;
  }

  int longest = 0;
  for (int i = 1; i <= num;)
  {
    int run = 1;
    int last = placement[i];
    while (i+run <= num && placement[i+run] > last)
    {
      last = placement[i + run];
      run += 1;
    }

    longest = max(run, longest);
    i += run;
  }

  printf("%d\n", num - longest);

  //vector<int> minValues(num);
  //vector<int> maxValues(num);
  //int mm = order.back();
  //for (int i = num - 1; i >= 0; --i)
  //{
  //  mm = min(order[i], mm);
  //  minValues[i] = mm;
  //}

  //mm = order.front();
  //for (int i = 0; i < num; ++i)
  //{
  //  mm = max(order[i], mm);
  //  maxValues[i] = mm;
  //}

  //vector<int> moved(num+1);
  //Fill(&moved, 0);

  //int res = 0;
  //for (int i = num-1; i >= 0; --i)
  //{
  //  int cur = order[i];
  //  if (cur == maxValues[i])
  //    continue;

  //  for (int j = cur; j > 0; j--)
  //  {
  //    if (!moved[j])
  //    {
  //      moved[j] = 1;
  //      res++;
  //    }
  //  }
  //}

  //printf("%d\n", res);

  ////int moveMin = 0;
  ////for (int i = 0; i < num; ++i)
  ////{
  ////  int cur = order[i];
  ////  if (cur != minValues[i])
  ////  {
  ////    moveMin += 1;
  ////  }
  ////}

  ////int moveMax = 0;
  ////for (int i = 0; i < num; ++i)
  ////{
  ////  int cur = order[i];
  ////  if (cur != maxValues[i])
  ////  {
  ////    moveMax += 1;
  ////  }
  ////}

  ////printf("%d\n", min(moveMax, moveMin));
  return 0;
}


#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
#include <list>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

template <typename T>
void Fill(vector<T>* cont, T val)
{
  for (size_t i = 0; i < cont->size(); ++i)
  {
    (*cont)[i] = val;
  }
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  vector<int> minValues(num);
  vector<int> maxValues(num);
  int mm = order.back();
  for (int i = num - 1; i >= 0; --i)
  {
    mm = min(order[i], mm);
    minValues[i] = mm;
  }

  mm = order.front();
  for (int i = 0; i < num; ++i)
  {
    mm = max(order[i], mm);
    maxValues[i] = mm;
  }

  vector<int> moved(num+1);
  Fill(&moved, 0);

  int moveMin = 0;
  for (int i = 0; i < num; ++i)
  {
    int cur = order[i];
    if (cur != minValues[i])
    {
      moveMin += 1;
    }
  }

  int moveMax = 0;
  for (int i = 0; i < num; ++i)
  {
    int cur = order[i];
    if (cur != maxValues[i])
    {
      moveMax += 1;
    }
  }

  printf("%d\n", min(moveMax, moveMin));
  return 0;
}


#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <deque>
#include <queue>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadVector()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

struct Node
{
  Node(int diff, int val, int idx) : diff(diff), val(val), idx(idx) {}
  int diff;
  int val;
  int idx;
};

struct NodeCmp
{
  bool operator()(const Node& lhs, const Node& rhs) { return lhs.diff < rhs.diff; }
};

bool IsSorted(const vector<int>& a)
{
  int prev = a[0];
  for (size_t i = 1; i < a.size(); ++i)
  {
    int v = a[i];
    if (v == -1)
      continue;
    if (a[i] < prev)
      return false;
    prev = a[i];
  }
  return true;
}

int main(int argc, char** argv)
{
  vector<int> tmp = ReadVector<int>();
  int num = tmp[0];
  vector<int> order = ReadVector<int>();

  priority_queue<Node, vector<Node>, NodeCmp> pq;

  for (int i = 0; i < (int)order.size(); ++i)
  {
    int val = order[i];
    pq.push(Node(abs(val - i), val, i));
  }

  int res = 0;
  while (true && !pq.empty())
  {
    if (IsSorted(order))
      break;

    Node n = pq.top();
    order[n.idx] = -1;
    res += 1;
    pq.pop();
  }

  printf("%d\n", res);
  return 0;
}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n];
        mems(barr,0);
        forr(n)
            {
                cin>>arr[i];
                barr[arr[i]-1]=barr[arr[i]-2]+1;
            }

            cout<<n-*max_element(barr,barr+n)<<endl;
    }

}


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n+1];
        mems(barr,0);
        forr(n+1)
        barr[i]=0;
        forr(n)
            {
                cin>>arr[i];
                //if(arr[i]>1)
                barr[arr[i]]=barr[arr[i]-1]+1;
            }

            cout<<n-(*max_element(barr+1,barr+n+1))<<endl;
    }

}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n];
        forr(n)
            cin>>arr[i];
        int pl,cnt,res=0;
        for(int i=0;i<n;i++)
            {
                pl=i;
                cnt=1;
                for(int j=i+1;j<n;j++)
                {
                    if(arr[j]== arr[pl]+1)
                        {cnt++;pl=j;}
                }
                res=max(res,cnt);
            }
            cout<<n-res<<endl;
    }

}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n];
        mems(barr,0);
        forr(n)
        barr[i]=0;
        forr(n)
            {
                cin>>arr[i];
                barr[arr[i]-1]=barr[arr[i]-2]+1;
            }

            cout<<n-(*max_element(barr,barr+n))<<endl;
    }

}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?
    #ifndef ONLINE_JUDGE
        freopen("a1.in","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int v,barr[n+1];
        mems(barr,0);
        forr(n)
        {
            cin>>v;
            barr[v]=barr[v-1]+1;
        }
        cout<<n-(*max_element(barr+1,barr+n+1))<<endl;
    }
}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n];
        mems(barr,0);
        forr(n)
            {
                cin>>arr[i];
                barr[arr[i]-1]=barr[arr[i]-2]+1;
            }

            cout<<n-*max_element(barr,barr+n)<<endl;
    }

}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n+1];
        mems(barr,0);
        forr(n)
        barr[i]=0;
        forr(n)
            {
                cin>>arr[i];
                if(arr[i]>1)
                barr[arr[i]]=barr[arr[i]-1]+1;
            }

            cout<<n-(*max_element(barr+1,barr+n+1))<<endl;
    }

}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?
    #ifndef ONLINE_JUDGE
        freopen("a1.in","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int v,barr[n+1],maxx=0;
        mems(barr,0);
        forr(n)
        {
            cin>>v;
            barr[v]=barr[v-1]+1;
            maxx= max(maxx,barr[v]);
        }
        n-=maxx;
        cout<<n<<endl;
    }
}
/**/


#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define s scanf
#define p printf
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
#define PI (double)3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);//Better safe than sorry?v
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    //int a,b,c,x,y,z;
    int n;
    while(cin>>n)
    {
        int arr[n],barr[n];
        mems(barr,0);
        forr(n)
        barr[i]=0;
        forr(n)
            {
                cin>>arr[i];
                if(arr[i]>1)
                barr[arr[i]-1]=barr[arr[i]-2]+1;
            }

            cout<<n-(*max_element(barr,barr+n))<<endl;
    }

}
/**/


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for(int i = 0; i < n-1; i++){
		if(a[i] > a[i-1]){
			cnt++;
		}
	}
	printf("%d\n", min(cnt, n-cnt));
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int x;
		scanf("%d", &x);
		a[x] = a[x-1] + 1;
		ans = max(ans, a[x]);
	}
	printf("%d\n", n-ans);
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int x;
		a[x] = a[x-1] + 1;
		ans = max(ans, a[x]);
	}
	printf("%d\n", n-ans);
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for(int i = 0; i < n-1; i++){
		if(a[i] > a[i+1]){
			cnt++;
		}
	}
	printf("%d\n", min(cnt, n-cnt-1));
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for(int i = 0; i < n-1; i++){
		if(a[i] > a[i-1]){
			cnt++;
		}
	}
	printf("%d\n", min(cnt, n-cnt-1));
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int cnt = 0;
	for(int i = 0; i < n-1; i++){
		if(a[i] > a[i+1]){
			cnt++;
		}
	}
	printf("%d\n", min(cnt, n-cnt));
}


#include<bits/stdc++.h>
using namespace std;
#define lld long long
int a[100010];
int lis(int arr[], int N)
{
    int i;
    set<int> s;
    set<int>::iterator k;
    for (i = 0; i<N; i++)
    {
        if (s.insert(arr[i]).second)
        {
            k = s.find(arr[i]);
            k++;
            if (k != s.end()) s.erase(k);
        }
    }
    return s.size();
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int l = lis(a, n);
    cout << n - l << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define lld long long
int a[100010];
int lis(vector<int> &A, int N)
{
    vector<int> ans;
    for (int i = 0; i<N; i++)
    {
        auto it = upper_bound(ans.begin(), ans.end(), A[i]);
        if (it == ans.end())
            ans.push_back(A[i]);
        else
            *it = A[i];
    }
    return ans.size();
}
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        v.push_back(a[i]);
    }
    int l = lis(v, n);
    cout << min(l,n-l) << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define lld long long
#define N 500010
int a[N];
int CeilIndex(int A[], int l, int r, int key)
{
    while (r - l > 1)
    {
        int m = l + (r - l) / 2;
        if (A[m] >= key)
            r = m;
        else
            l = m;
    }
    return r;
}
int LongestIncreasingSubsequenceLength(int A[], int size)
{
    // Add boundary case, when array size is one

    int *tailTable = new int[size];
    int len; // always points empty slot

    memset(tailTable, 0, sizeof(tailTable[0])*size);

    tailTable[0] = A[0];
    len = 1;
    for (int i = 1; i < size; i++)
    {
        if (A[i] < tailTable[0])
            // new smallest value
            tailTable[0] = A[i];

        else if (A[i] > tailTable[len - 1])
            // A[i] wants to extend largest subsequence
            tailTable[len++] = A[i];

        else
            tailTable[CeilIndex(tailTable, -1, len - 1, A[i])] = A[i];
    }

    delete[] tailTable;
    return len;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int l=LongestIncreasingSubsequenceLength(a, n);
    cout << n - l << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define lld long long
int a[100010];
int lis(vector<int> &A, int N)
{
    vector<int> ans;
    for (int i = 0; i<N; i++)
    {
        auto it = upper_bound(ans.begin(), ans.end(), A[i]);
        if (it == ans.end())
            ans.push_back(A[i]);
        else
            *it = A[i];
    }
    return ans.size();
}
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        v.push_back(a[i]);
    }
    int l = lis(v, n);
    cout << n - l << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define lld long long
typedef vector<int> vi;
typedef pair<int,int> ii;
void open(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}
int a[N],maxcnt=0,n;
void solve()
{
    int pos[N],cnt=0;
    pos[0]=0;
    for(int i=1;i<=n;i++)
        pos[a[i]]=i;
    for(int i=1;i<=n;i++)
    {
        if(pos[i]>pos[i-1])
            cnt++;
        else
            cnt=1;
        if(cnt>maxcnt)
            maxcnt=cnt;
        //cout<<cnt<<" ";
    }
}
int main()
{
    //open();
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    solve();
    cout<<maxcnt<<endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define Pq priority_queue
#define u_set unordered_set
#define MOD 1000000007
#define MAXN 100001
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define scan(n) scanf("%d", &n)
#define scanP(x,y) scanf("%d %d", &x, &y)
#define scanPL(x,y) scanf("%lld %lld", &x, &y)
#define FOR(i,from,to) for (int i=from; i<to; i++)
#define B() begin()
#define E() end()
#define F first
#define S second

int main() {
	ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> idx;
		map<int,int> one,two;
		FOR(i,0,s.size()-2){
			if(s[i] == 't') {
				if(s[i+1] == 'w' && s[i+2] == 'o') two[i] = 1;
			}
			if(s[i] == 'o') {
				if(s[i+1] == 'n' && s[i+2] == 'e') one[i] = 1;
			}
		}
		FOR(i,0,s.size()-2){
			if(two[i]){
				if(one[i+2]) {
					idx.pb(i+2);
					one[i+2] = 0;
				} else idx.pb(i+1);
			}
			if(one[i]) idx.pb(i+1);
		}
		cout << idx.size() << endl;
		for(auto x : idx){
			cout << x+1 << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define Pq priority_queue
#define u_set unordered_set
#define MOD 1000000007
#define MAXN 100001
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define scan(n) scanf("%d", &n)
#define scanP(x,y) scanf("%d %d", &x, &y)
#define scanPL(x,y) scanf("%lld %lld", &x, &y)
#define FOR(i,from,to) for (int i=from; i<to; i++)
#define B() begin()
#define E() end()
#define F first
#define S second

int main() {
	ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		s += "$$";
		vector<int> idx;
		map<int,int> one,two;
		FOR(i,0,s.size()-4){
			if(s[i] == 't') {
				if(s[i+1] == 'w' && s[i+2] == 'o') {
					if(s[i+3] == 'n' && s[i+4] == 'e') {
						idx.pb(i+2);
						s[i+2] = '$';
					}else{
						idx.pb(i+1);
					}
				}
			}
			if(s[i] == 'o') {
				if(s[i+1] == 'n' && s[i+2] == 'e') {
					idx.pb(i+1);
				}
			}
		}

		cout << idx.size() << endl;
		for(auto x : idx){
			cout << x+1 << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define Pq priority_queue
#define u_set unordered_set
#define MOD 1000000007
#define MAXN 100001
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define scan(n) scanf("%d", &n)
#define scanP(x,y) scanf("%d %d", &x, &y)
#define scanPL(x,y) scanf("%lld %lld", &x, &y)
#define FOR(i,from,to) for (int i=from; i<to; i++)
#define B() begin()
#define E() end()
#define F first
#define S second

int main() {
	ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		vector<int> idx;
		map<int,int> one,two;
		FOR(i,0,s.size()-2){
			if(s[i] == 't') {
				if(s[i+1] == 'w' && s[i+2] == 'o') two[i] = 1;
			}
			if(s[i] == 'o') {
				if(s[i+1] == 'n' && s[i+2] == 'e') one[i] = 1;
			}
		}
		FOR(i,0,s.size()-2){
			if(two.count(i)){
				if(one.count(i+2)) {
					idx.pb(i+2);
					one[i+2] = 0;
				} else idx.pb(i+1);
			}
			if(one.count(i) && one[i]) idx.pb(i+1);
		}
		cout << idx.size() << endl;
		for(auto x : idx){
			cout << x+1 << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		cnt=0;
		vector<ll>v,ans;
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
				v.pb(i);
		}
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
				v.pb(i);
		}
		sort(v.begin(),v.end());
		for(i=0;i<(ll)v.size()-1;i++)
		{
			if(v[i+1]-v[i]>=3)
			{
				ans.pb(v[i]+2);
				cnt++;
			}
			else
			{
				i++;
				cnt++;
				ans.pb(v[i]+1);
			}
		}
		if(i<v.size())
		{
			cnt++;
			ans.pb(v[v.size()-1]+2);
		}
		cout<<cnt<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";
		cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		cnt=0;
		vector<ll>v,ans;
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
				v.pb(i);
		}
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
				v.pb(i);
		}
		sort(v.begin(),v.end());
		for(i=0;i<(ll)v.size()-1;i++)
		{
			if(v[i+1]-v[i]>=3)
			{
				ans.pb(v[i]+2);
				cnt++;
			}
			else
			{
				i++;
				ans.pb(v[i]+1);
			}
		}
		if(v.size()>0)
		{
			cnt++;
			ans.pb(v[v.size()-1]+2);
		}
		cout<<cnt<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";
		cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		cnt=0;
		vector<ll>v,ans;
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
				v.pb(i);
		}
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
				v.pb(i);
		}
		sort(v.begin(),v.end());
		for(i=0;i<(ll)v.size()-1;i++)
		{
			if(v[i+1]-v[i]>=3)
			{
				ans.pb(v[i]+2);
				cnt++;
			}
			else
			{
				i++;
				ans.pb(v[i]+1);
			}
		}
		if(i<v.size())
		{
			cnt++;
			ans.pb(v[v.size()-1]+2);
		}
		cout<<cnt<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";
		cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		vector<ll>ans;
		for(i=0;i<(ll)str.size()-2;i++)
		{
			if(i+4<str.size()&&str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o'&&str[i+3]=='n'&&str[i+4]=='e')
			{
				//debug(i+2);
				ans.pb(i+2);
				i=i+4;
			}
			else if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
			{
				//debug(i+1);
				ans.pb(i+1);
				i=i+2;
			}
			else if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
			{
				//sdebug(i+1);
				ans.pb(i+1);
				i=i+2;
			}
		}
		cout<<ans.size()<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]+1<<" ";
		cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		cnt=0;
		vector<ll>v,ans;
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
				v.pb(i);
		}
		for(i=0;i<str.size()-2;i++)
		{
			if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
				v.pb(i);
		}
		sort(v.begin(),v.end());
		for(i=0;i<(ll)v.size()-1;i++)
		{
			if(v[i+1]-v[i]>=3)
			{
				ans.pb(v[i]+1);
				cnt++;
			}
		}
		if(v.size()>0)
		{
			cnt++;
			ans.pb(v[v.size()-1]+1);
		}
		cout<<cnt<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";
		cout<<"\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll t,cnt,i;
	string str;
	cin>>t;
	while(t--)
	{
		cin>>str;
		vector<ll>ans;
		for(i=0;i<str.size()-2;i++)
		{
			if(i+4<str.size()&&str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o'&&str[i+3]=='n'&&str[i+4]=='e')
			{
				//debug(i+2);
				ans.pb(i+2);
				i=i+4;
			}
			else if(str[i]=='t'&&str[i+1]=='w'&&str[i+2]=='o')
			{
				//debug(i+1);
				ans.pb(i+1);
				i=i+2;
			}
			else if(str[i]=='o'&&str[i+1]=='n'&&str[i+2]=='e')
			{
				//sdebug(i+1);
				ans.pb(i+1);
				i=i+2;
			}
		}
		cout<<ans.size()<<"\n";
		for(i=0;i<ans.size();i++)
			cout<<ans[i]+1<<" ";
		cout<<"\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {//cout<<i<<endl;

            if(i+2<s.size()&&s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(i+4<s.size()&&s[i+3]=='n'&&s[i+4]=='e')
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(i+2<s.size()&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=15e5+5;
char s[N];
int len=0;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s+1;
        len=strlen(s+1);
        vector<int>ans;
        for(int i=1;i<=len-2;i++)
        {//cout<<i<<endl;

            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<=len)
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {
            if(i>s.size()) break;
            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<s.size())
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include <cstdio>
#include <cstring>
#define min(a, b) (a > b ? b : a)
using namespace std;
const int N = 15e5 + 5;
char s[N];
int t, cnt, len, path[N];
int main() {
	scanf("%d", &t);
	while (t--) {
 		cnt = 0;
		scanf("%s", s + 1);
		len = strlen(s + 1);
		for (int i = 1; i <= len - 2; i++) {
			if (s[i] == 'o' && s[i + 1] == 'n' && s[i + 2] == 'e') path[++cnt] = i + 1, i += 2;
			if (s[i] == 't' && s[i + 1] == 'w' && s[i + 2] == 'o') {
				if (s[i + 3] == 'n' && s[i + 4] == 'e') path[++cnt] = i + 2, i += 4;
				else path[++cnt] = i + 1, i += 2;
			}
		}
		printf("%d\n", cnt);
		for (int i = 1; i <= cnt; i++) {
			printf("%d ", path[i]);
		}
		puts("");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=15e5+5;
char s[N];
int len=0;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s+1;
        len=strlen(s+1);
        vector<int>ans;
        for(int i=1;i<=len-2;i++)
        {//cout<<i<<endl;

            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<=len)
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int T;cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {
            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<s.size())
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {//cout<<i<<endl;

            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<s.size())
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {//cout<<i<<endl;
            if(i+4<s.size()&&s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o'&&s[i+3]=='n'&&s[i+4]=='e')
            {
                ans.push_back(i+2);
                i+=4;
            }
            else if(i+2<s.size()&&s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                ans.push_back(i+1);
                i+=2;
            }
            else if(i+2<s.size()&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int T;cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        vector<int>ans;
        int len=s.size();
        for(int i=0;i<=len-3;i++)
        {
            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(s[i+3]=='n'&&s[i+4]=='e'&&i+4<s.size())
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {//cout<<i<<endl;
            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o'&&s[i+3]=='n'&&s[i+4]=='e')
            {
                ans.push_back(i+2);
                i+=4;
            }
            else if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                ans.push_back(i+1);
                i+=2;
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1;
string s;
int main()
{
    int T;cin>>T;
    while(T--)
    {
        cin>>s;
        vector<int>ans;
        for(int i=0;i<=s.size()-3;i++)
        {//cout<<i<<endl;

            if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o')
            {
                if(i+4<s.size()&&s[i+3]=='n'&&s[i+4]=='e')
                {
                    ans.push_back(i+2);
                    i+=4;
                }
                else
                {
                    ans.push_back(i+1);
                    i+=2;
                }
            }
            else if(s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e')
            {
                ans.push_back(i+1);
                i+=2;
            }
        }
        cout<<ans.size()<<endl;
        for(int i=0;i<ans.size();i++) cout<<ans[i]+1<<" ";
        cout<<endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		vector <int> ind;
		for (int j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					ind.push_back(j + 2);
				}
				else {
					ind[ind.size() - 1]++;
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				ind.push_back(j + 2);
			}
		}
		cout << ind.size() << endl;
		for (auto el : ind) {
			cout << el << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
		s.erase(s.begin(), s.end());
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		vector <int> ind;
		for (int j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					ind.push_back(j + 2);
				}
				else {
					ind[ind.size() - 1]++;
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				ind.push_back(j + 2);
			}
		}
		cout << ind.size() << endl;
		for (auto el : ind) {
			cout << el << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		vector <int> ind;
		if (s.size() >= 3) {
			for (int j = 0; j < s.size() - 2; j++) {
				if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
					if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
						ind.push_back(j + 2);
					}
					else {
						ind[ind.size() - 1]++;
					}
				}
				if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
					ind.push_back(j + 2);
				}
			}
		}
		cout << ind.size() << endl;
		for (auto el : ind) {
			cout << el << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
		s.erase(s.begin(), s.end());
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		long long answer = 0;
		vector <int> ind;
		for (int j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					answer++;
					ind.push_back(j + 2);
				}
				else {
					ind[ind.size() - 1]++;
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				answer++;
				ind.push_back(j + 2);
			}
		}
		cout << answer << endl;
		for (int j = 0; j < answer; j++) {
			cout << ind[j] << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long long t;
	cin >> t;
	for (long long i = 0; i < t; i++) {
		string s;
		cin >> s;
		long long answer = 0;
		vector <long long> ind;
		for (long long j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					answer++;
					ind.push_back(j + 2);
				}
				else {
					ind[ind.size() - 1]++;
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				answer++;
				ind.push_back(j + 2);
			}
		}
		cout << answer << endl;
		for (long long j = 0; j < answer; j++) {
			cout << ind[j] << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
	}
}


#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		long long answer = 0;
		vector <int> ind;
		for (int j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					answer++;
					ind.push_back(j + 2);
				}
				else {
					ind[ind.size() - 1]++;
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				answer++;
				ind.push_back(j + 2);
			}
		}
		cout << answer << endl;
		for (int j = 0; j < answer; j++) {
			cout << ind[j] << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
	}
}


#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		cin >> s;
		long long answer = 0;
		vector <int> ind;
		for (int j = 0; j < s.size() - 2; j++) {
			if (s[j] == 'o' && s[j + 1] == 'n' && s[j + 2] == 'e') {
				if (j < 2 || s[j - 2] != 't' || s[j - 1] != 'w') {
					answer++;
					ind.push_back(j + 3);
				}
			}
			if (s[j] == 't' && s[j + 1] == 'w' && s[j + 2] == 'o') {
				answer++;
				ind.push_back(j + 3);
			}
		}
		cout << answer << endl;
		for (int j = 0; j < answer; j++) {
			cout << ind[j] << " ";
		}
		cout << endl;
		ind.erase(ind.begin(), ind.end());
	}
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE],rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i+1;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                s[i]='a';
                rec[ans]=i+1;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++)
            if (i==1)
                printf("%d",rec[i]);
            else
                printf(" %d",rec[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE],rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i+1;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                if (i==len-1 || s[i+1]!='o')
                {
                    rec[ans]=i+1;
                    s[i]='a';
                }
                else
                    rec[ans]=i;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++)
            if (i==1)
                printf("%d",rec[i]);
            else
                printf(" %d",rec[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE],rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                if (i==len-1 || s[i+1]!='o')
                {
                    rec[ans]=i+1;
                    s[i]='a';
                }
                else
                    rec[ans]=i;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++)
            if (i==1)
                printf("%d",rec[i]);
            else
                printf(" %d",rec[i]);
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE],rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                s[i]='a';
                rec[ans]=i;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++) printf("%d%c",rec[i],i==ans?'\0':' ');
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE],rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i+1;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                s[i]='a';
                rec[ans]=i+1;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++) printf("%d%c",rec[i],i==ans?'\0':' ');
        printf("\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int SIZE=1.5e5+5;
char s[SIZE];
int rec[SIZE];
int main()
{
    int T,len;
    cin>>T;
    while(T--)
    {
        scanf("%s",s);
        len=strlen(s);
        int ans=0;
        for (int i=2;i<len;i++)
        {
            if (s[i-2]=='o' && s[i-1]=='n' && s[i]=='e')
            {
                ans++;
                rec[ans]=i;
            }
            if (s[i-2]=='t' && s[i-1]=='w' && s[i]=='o')
            {
                ans++;
                if (i==len-1 || s[i+1]!='o')
                {
                    rec[ans]=i+1;
                    s[i]='a';
                }
                else
                    rec[ans]=i;
            }
        }
        printf("%d\n",ans);
        for (int i=1;i<=ans;i++)
            if (i==1)
                printf("%d",rec[i]);
            else
                printf(" %d",rec[i]);
        printf("\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(1500001, 0);
        for(int i=2; i<s.size(); i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if((i<s.size()-2)&&s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(200000, 0);
        s = s + "pppppp";
        for(int i=2; i<s.size()-6; i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(15000, 0);
        for(int i=2; i<s.size(); i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
                s[i-1] = 'z';
            }
            else if((i<s.size()-2)&&s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
                s[i+1] = 'z';
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
                s[i-1] = 'z';
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
                s[i-1] = 'z';
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(15001, 0);
        if(s.size()<=2) cout<<"0\n\n";
        s = s + "pppppp";
        for(int i=2; i<s.size()-6; i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(15001, 0);
        for(int i=2; i<s.size(); i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if((i<s.size()-2)&&s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(15000, 0);
        for(int i=2; i<s.size(); i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if((i<s.size()-2)&&s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(15001, 0);
        s = s + "pppppp";
        for(int i=2; i<s.size()-6; i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define str string
#define ch char
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        vector<int> ans;
        vector<int> checked(20000, 0);
        for(int i=2; i<s.size(); i++){
            if(i>=4&&s[i-4]=='t'&&s[i-3]=='w'&&s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i-1]==0)
                    ans.pb(i-1);
                checked[i-1] = 1;
            }
            else if((i<s.size()-2)&&s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'&&s[i+1]=='n'&&s[i+2]=='e'){
                if(checked[i+1]==0)
                    ans.pb(i+1);
                checked[i+1] = 1;
            }
            else if(s[i-2]=='o'&&s[i-1]=='n'&&s[i]=='e'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
            else if(s[i-2]=='t'&&s[i-1]=='w'&&s[i]=='o'){
                if(checked[i]==0)
                    ans.pb(i);
                checked[i] = 1;
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";
    }
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  int t;cin>>t;
  rep(hoge,t){
    string s;
    cin>>s;
    s += "xxxxxx";
    ll ans = 0;
    vector<ll> pos;
    rep(si,s.size()-5){
      if(s[si] == 'o' && s[si+1] == 'n' && s[si+2] == 'e'){
        s[si+1] = 'x';
        pos.push_back(si+1+1);
        ans++;
        si--;
        continue;
      }
      if(s[si] == 't' && s[si+1] == 'w' && s[si+2] == 'o' && s[si+3] == 'n' && s[si+4] == 'e'){
        s[si+2] = 'x';
        pos.push_back(si+2+1);
        ans++;
        si--;
        continue;
      }
      if(s[si] == 't' && s[si+1] == 'w' && s[si+2] == 'o'){
        s[si+1] = 'x';
        pos.push_back(si+1+1);
        ans++;
        si--;
        continue;
      }
    }
    cout<<ans<<endl;
    rep(i,pos.size()){
      cout<<pos[i]<<" ";
    }
    cout<<endl;
  }
  return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mp make_pair
#define pb push_back
#define ll long long
#define li long int
#define ST string
#define ld long double
#define st string

#define fo(i,a,b) for(ll i=a; i<=b; i++)
#define re(i,a,b) for(ll i=a; i>=b; i--)
#define fop(i,a,b) for(ll i=a; i<b; i++)
#define rep(i,a,b) for(ll i=a-1; i>=b; i--)

#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define N 1000002
#define M 2000
#define MOD 1000000009

typedef pair<int, int> II;
typedef pair<int, II> III;
typedef pair<ll, ll> LL;
typedef pair<ll, LL> LLL;
typedef pair<ld,ld> PD;
typedef pair<II,II> IG;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<ll> VL;
typedef vector<VL > VVL;
typedef vector<ld> VD;
typedef complex<ld> cd;

const int INF = 2147483647;
const long double PI = 3.1415926535898;
const long long oo = 9223372036854775807;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

template<class T> T getbit(T s, int i){return (s >> i) & 1;}
template<class T> T onbit(T s, int i){return s | (T(1) << i);}
template<class T> T offbit(T s, int i){return s & (~(T(1) << i));}
template<class T> T dembit(T s){return __builtin_popcountt(s);}

template<class T> T gcd(T a, T b){T r; while (b != 0){r = a % b; a = b; b = r;} return a;}
template<class T> T lcm(T a, T b){return a / gcd(a, b) * b;}

template <typename T> T Max(T a, T b){return a > b ? a : b;}
template <typename T> T Min(T a, T b){return a < b ? a : b;}
template <typename T> T abs(T a){return a > 0 ? a : -a;}

template <typename T> ll pow(T a, T b){ll res = 1; fo(i,1,b) res = res * a; return res;}

template<class T> void read(T &x)
{
    x = 0;
    char c;
    for(c = getchar(); c < '0' || c > '9'; c = getchar());
    x = c - '0';
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
}

template<class T> void readchar(T &x)
{
    for(x = getchar(); x != 'D' && x != 'C'; x = getchar());
}

template <typename T> inline void writep(T x){ if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){ if(x<0){ putchar('-'); x=-x; } writep(x);}
template <typename T> inline void writeln(T x){ write(x); putchar('\n'); }
template <typename T> inline void writec(T x){ write(x); putchar(' ');}

int n , T , res;
int dx[] = {'t' , 'w' , 'o' , 'n' , 'e'};
int dem[N] , ppp[N];
int d1[] = {'o' , 'n' , 'e'} , d2[] = {'t' , 'w' , 'o'};
char f[N];
IG a[N];
VI qq;
vector < II > g;

main()
{
    fast
    cin >> T;
    while(T--)
    {
        int r = 0;
        cin >> f;
        int n = strlen(f);
        re(i , n , 1)
            f[i] = f[i - 1];
        f[n + 1] = 0;
        int bd = 1;
        fo(i , 2 , n + 1)
            if(f[i] != f[i - 1])
                a[++r] = IG(II(f[i - 1] , i - bd) , II(bd , i - 1)) , bd = i;
        qq.clear();
        fo(i , 1 , r)
        {
            bool ok = true;
            if(i + 2 <= r)
            {
                bool ok = true;
                fo(s ,0, 4)
                    dem[dx[s]] = 0;
                fo(j , 0 , 2)
                {
                    if(a[i + j].fi.fi != d1[j])
                        ok = false;
                    dem[a[i + j].fi.fi] += a[i + j].fi.se;
                    ppp[a[i + j].fi.fi] = i + j;
                }
                if(ok && dem['o'] != 0 && dem['n'] == 1 && dem['e'] != 0)
                {
                        int pn = ppp['n'];
                        fo(i , a[pn].se.fi , a[pn].se.se)
                            qq.pb(i);
                        a[pn].fi.se = 0;
                }
                ok = true;
                fo(s ,0, 4)
                    dem[dx[s]] = 0;
                fo(j , 0 , 2)
                {
                    if(a[i + j].fi.fi != d2[j])
                        ok = false;
                    dem[a[i + j].fi.fi] += a[i + j].fi.se;
                    ppp[a[i + j].fi.fi] = i + j;
                }
                if(ok && dem['t'] != 0 && dem['o'] != 0 && dem['w'] == 1)
                {
                    if(dem['o'] <= dem['w'])
                    {
                        int pn = ppp['o'];
                        fo(i , a[pn].se.fi , a[pn].se.se)
                                qq.pb(i);
                        a[pn].fi.se = 0;
                    }
                    else
                    {
                        int pn = ppp['w'];
                        fo(i , a[pn].se.fi , a[pn].se.se)
                                qq.pb(i);
                        a[pn].fi.se = 0;
                    }
                }
            }
        }
        cout << qq.size() << '\n';
        fo(pq ,0, qq.size()-1)
            cout << qq[pq] << " ";
        cout << '\n';
    }
}


#include<bits/stdc++.h>
using namespace std;

#define ii pair < int , int >
#define ig pair < ii , ii >
#define ll long long
#define fi first
#define se second
#define pb push_back

#define fo(i , x , n) for(int i = x ; i <= n ; ++i)
#define re(i , n) for(int i = 0 ; i < n ; ++i)
#define fod(i , x , n) for(int i = x ; i >= n ; --i)
template<class T> T getbit(T s, int i){return (s >> i) & 1;}
template<class T> T onbit(T s, int i){return s | (T(1) << i);}
template<class T> T offbit(T s, int i){return s & (~(T(1) << i));}
template<class T> T cntbit(T s){return __builtin_popcountt(s);}

template<class T> T gcd(T a, T b){T r; while (b != 0){r = a % b; a = b; b = r;} return a;}
template<class T> T lcm(T a, T b){return a / gcd(a, b) * b;}

template <typename T> T Max(T a, T b){return a > b ? a : b;}
template <typename T> T Min(T a, T b){return a < b ? a : b;}
template <typename T> T abs(T a){return a > 0 ? a : -a;}

template <typename T> ll pow(T a, T b){ll res = 1; fo(i,1,b) res = res * a; return res;}

template<class T> void read(T &x)
{
    x = 0;
    char c;
    for(c = getchar(); c < '0' || c > '9'; c = getchar());
    x = c - '0';
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
}

template<class T> void readchar(T &x)
{
    for(x = getchar(); x != 'D' && x != 'C'; x = getchar());
}

template <typename T> inline void writep(T x){ if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){ if(x<0){ putchar('-'); x=-x; } writep(x);}
template <typename T> inline void writeln(T x){ write(x); putchar('\n'); }
template <typename T> inline void writec(T x){ write(x); putchar(' ');}

#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const int mm = 1e6 + 5;
int n , T , res;
int dx[] = {'t' , 'w' , 'o' , 'n' , 'e'};
int cnt[mm] , dp[mm];
int d1[] = {'o' , 'n' , 'e'} , d2[] = {'t' , 'w' , 'o'};
char f[mm];
ig a[mm];
vector < int > ats;
vector < ii > g;

main ()
{
fast
    cin >> T;
    while(T--)
    {
        int r = 0;
        cin >> f;
        int n = strlen(f);
        fod(i , n , 1)
            f[i] = f[i - 1];
        f[n + 1] = 0;
        int bd = 1;
        fo(i , 2 , n + 1)
            if(f[i] != f[i - 1])
                a[++r] = ig (ii(f[i - 1] , i - bd) , ii(bd, i - 1)) , bd= i;
        ats.clear();
        fo(i , 1 , r)
        {
            bool ok = true;
            if(i + 2 <= r)
            {
                bool ok = true;
                re(s , 5)
                    cnt[dx[s]] = 0;
                fo (j , 0 , 2)
                {
                    if(a[i + j].fi.fi != d1[j])
                        ok = false;
                    cnt[a[i + j].fi.fi] += a[i + j].fi.se;
                    dp[a[i + j].fi.fi] = i + j;
                }
                if(ok && cnt['o'] != 0 && cnt['n'] == 1 && cnt['e'] != 0)
                {
                        int pos = dp['n'];
                        fo (i , a[pos].se.fi , a[pos].se.se)
                            ats.pb(i);
                        a[pos].fi.se = 0;
                }
                ok = true;
                re (s , 5)
                    cnt[dx[s]] = 0;
                fo (j , 0 , 2)
                {
                    if(a[i + j].fi.fi != d2[j])
                        ok = false;
                    cnt[a[i + j].fi.fi] += a[i + j].fi.se;
                    dp[a[i + j].fi.fi] = i + j;
                }
                if(ok && cnt['t'] != 0 && cnt['o'] != 0 && cnt['w'] == 1)
                {
                    if(cnt['o'] <= cnt['w'])
                    {
                        int pos = dp['o'];
                        fo(i , a[pos].se.fi , a[pos].se.se)
                                ats.pb(i);
                        a[pos].fi.se = 0;
                    }
                    else
                    {
                        int pos = dp['w'];
                        fo(i , a[pos].se.fi , a[pos].se.se)
                                ats.pb(i);
                        a[pos].fi.se = 0;
                    }
                }
            }
        }
        cout << ats.size() << "\n";
        re(ss , ats.size())
            cout << ats[ss] << " ";
        cout << "\n";
    }
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define mp make_pair
#define pb push_back
#define ll long long
#define li long int
#define ST string
#define ld long double
#define st string

#define fo(i,a,b) for(ll i=a; i<=b; i++)
#define re(i,a,b) for(ll i=a; i>=b; i--)
#define fop(i,a,b) for(ll i=a; i<b; i++)
#define rep(i,a,b) for(ll i=a-1; i>=b; i--)

#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

#define N 2000000
#define M 2000
#define MOD 1000000009

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> II;
typedef pair<int, II> III;
typedef pair<ll, ll> LL;
typedef pair<ll, LL> LLL;
typedef pair<ld,ld> PD;
typedef pair<LL,LL> IG;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<ll> VL;
typedef vector<VL > VVL;
typedef vector<ld> VD;
typedef complex<ld> cd;

const int INF = 2147483647;
const long double PI = 3.1415926535898;
const long long oo = 9223372036854775807;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

template<class T> T getbit(T s, int i){return (s >> i) & 1;}
template<class T> T onbit(T s, int i){return s | (T(1) << i);}
template<class T> T offbit(T s, int i){return s & (~(T(1) << i));}
template<class T> T dembit(T s){return __builtin_popcountt(s);}

template<class T> T gcd(T a, T b){T r; while (b != 0){r = a % b; a = b; b = r;} return a;}
template<class T> T lcm(T a, T b){return a / gcd(a, b) * b;}

template <typename T> T Max(T a, T b){return a > b ? a : b;}
template <typename T> T Min(T a, T b){return a < b ? a : b;}
template <typename T> T abs(T a){return a > 0 ? a : -a;}

template <typename T> ll pow(T a, T b){ll res = 1; fo(i,1,b) res = res * a; return res;}

template<class T> void read(T &x)
{
    x = 0;
    char c;
    for(c = getchar(); c < '0' || c > '9'; c = getchar());
    x = c - '0';
    for(c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
}

template<class T> void readchar(T &x)
{
    for(x = getchar(); x != 'D' && x != 'C'; x = getchar());
}

template <typename T> inline void writep(T x){ if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){ if(x<0){ putchar('-'); x=-x; } writep(x);}
template <typename T> inline void writeln(T x){ write(x); putchar('\n'); }
template <typename T> inline void writec(T x){ write(x); putchar(' ');}

int x1[] = {'o' , 'n' , 'e'};
int x2[] = {'t' , 'w' , 'o'};
int x[]={'t','w','o','n','e'};
ll n;
int dem[N],qq[N];
char f[N];
IG khu[N];
VI qqq;

main()
{
    fast
    ll T;
    cin>>T;
    while(T--)
    {
        cin>>f;
        n=strlen(f);
        re(i,n,1)
            f[i]=f[i-1];
        f[n+1] = 0;
        int bd=1,r=0;
        fo(i,2,n+1)
            if(f[i]!=f[i - 1])
                {
                    khu[++r]=IG(II(f[i-1],i-bd),II(bd,i-1));
                    bd=i;
                }
        qqq.clear();
    fo(i,1,r)
        {
            bool check = true;
            if(i+2<=r)
            {
                bool check = true;
                fo(ii,0,4)
                    dem[x[ii]] = 0;
                fo(ppp,0,2)
                {
                    if(khu[i+ppp].first.first!=x1[ppp])
                        check=false;
                    dem[khu[i+ppp].first.first]+=khu[i+ppp].first.se;
                    qq[khu[i+ppp].first.first]=i+ppp;
                }
                if(check && dem['o'] != 0 && dem['n'] == 1 && dem['e'] != 0)
                {
                        int pn = qq['n'];
                        fo(i , khu[pn].se.first , khu[pn].se.se)
                            qqq.pb(i);
                        khu[pn].first.se = 0;
                }
                check = true;
                fo(pppp,0,4)
                    dem[x[pppp]] = 0;
                fo(j,0,2)
                {
                    if(khu[i + j].first.first != x2[j])
                        check = false;
                    dem[khu[i + j].first.first] += khu[i + j].first.se;
                    qq[khu[i + j].fi.fi] = i + j;
                }
                if(check && dem['t'] != 0 && dem['o'] != 0 && dem['w'] == 1)
                {
                    if(dem['o'] <= dem['w'])
                    {
                        int pn = qq['o'];
                        fo(i , khu[pn].se.first , khu[pn].se.se)
                                qqq.pb(i);
                        khu[pn].first.se = 0;
                    }
                    else
                    {
                        int pn = qq['w'];
                        fo(i , khu[pn].se.first , khu[pn].se.se)
                                qqq.pb(i);
                        khu[pn].first.se = 0;
                    }
                }
            }
        }
        cout<<qqq.size()<<'\n';
        fo(s,0,qqq.size()-1)
            cout << qqq[s] << " ";
        cout << '\n';
    }
}