#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e+9+7;


int main(){
	int n;
	string s;
	cin >> n >> s;
	string ss="";
	int ans = 0;
	for(int i=0; i<n; i++){
		if(s[i]=='f' || s[i]=='o' || s[i]=='x'){
			ss+=s[i];
			int len = ss.length();
			if(len>=3){
				if(ss[len-3]=='f' && ss[len-2]=='o' && ss[len-1]=='x'){
					ans++;
					ss = ss.substr(0,len-3);
				}
			}
		}else{
			ss="";
		}
		//cout << i << " " << ss << " " << endl;
	}
	cout << n-ans*3 << endl;
	return 0;
}
#include <cstdio>
#include <cstring>
#include <iostream>

#define int long long

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template <class T>
T read(T &num) {
    T    x = 0, f = 1;
    char ch = getchar();
    while (ch > '9' || ch < '0') {
        if (ch == '-') {
            f = -1;
        }
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x  = x * 10 + ch - '0';
        ch = getchar();
    }
    num = x * f;
    return num;
}

const int N = 1e5 + 5;
int n;
int a, p, x;
double aa;
int ans = 0x3f3f3f3f;

signed main() {
    read(n);
    for(int i = 1; i <= n; i++){
        read(a), read(p), read(x);
        if(a < x) ans = min(ans, p);
    }
    if(ans == 0x3f3f3f3f) cout<<-1;
    else cout<<ans;
    return 0;
}