#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

const ll INF = 1e18;

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll ans = n;
    vector<int>cnt;
    rep(i, n) {
        if (s[i] == 'f')cnt.push_back(1);
        else if (s[i] == 'o')cnt.push_back(2);
        else if (s[i] == 'x')cnt.push_back(3);
        else cnt.push_back(0);
        int size = cnt.size();
        //cout << i << ' ' << size << endl;
        if (size >= 3 && cnt[size - 3] == 1 && cnt[size - 2] == 2 && cnt[size-1] == 3) {
            ans -= 3;
            rep(j, 3)cnt.pop_back();
        }
        
    }
   
    cout << ans << endl;

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  REP(i,n)cin>>v[i];
  REP(i,n)v[i]--;
  set<int> rem;
  REP(i,n-1)if(v[i]>i&&v[i+1]<i+1)rem.insert(i);
  vector<int> ans;
  while(rem.size()){
    int p=*rem.begin();
    ans.push_back(p);
    rem.erase(p);
    swap(v[p],v[p+1]);
    for(int i=p-1;i<=p+1;i++)if(~i&&v[i]>i&&v[i+1]<i+1)rem.insert(i);
  }
  if(ans.size()!=n-1)fin(-1);
  REP(i,n)if(i!=v[i])fin(-1);
  for(int p:ans)cout<<p+1<<endl;
}
