#include <bits/stdc++.h>
// #include "icld.cpp"
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using ss = string;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//#define pi 3.14159265358979
#define ss string
#define db double
#define rep(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define ci(x) cin >> (x)
#define cii(x) int (x);cin >> (x)
#define cci(x,y) int (x),(y);cin >> (x) >>(y)
#define co(x) cout << (x) << endl

int t[200010];
int main(){
  cii(n);
  vi v(n);
  rep(i,0,n)ci(v[i]);
  int at=0;
  rep(i,0,n){
  t[v[i]]++;
  while(t[at])at++;
  co(at);
  }
}
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll n;cin>>n;
	stack<char> st;
	ll ans = n;
	string s;cin>>s;
	rep(i,0,n) {
		st.push(s[i]);

		while(1) {
			ll cnt = 0;
			if(!st.empty() and st.top() == 'x' ) {
				cnt ++;
				st.pop();
				if(!st.empty() and st.top() == 'o' ) {
					cnt ++;
					st.pop();
					if(!st.empty() and st.top() == 'f' ) {
						cnt ++;
						st.pop();
					}
				}
			}
			//test2(i,cnt);
			if(cnt == 3) {
				ans -=3;
			}
			else {
				if(cnt == 1) {
					st.push('x');
				}
				if(cnt == 2) {
					st.push('o');
					st.push('x');
				}
				break;
			}
		}
	}
	cout << ans  << endl;
}