#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a,b,c) for(int a = b; a >= c; --a)
#define pb push_back
#define int long long
#define SZ(a) (int)(a.size())
#define mtp make_tuple
 
const int MOD = 998244353;
const int oo = 1e9;
const int mod = 1e9 + 7;
const int N = 2e5 + 100;
const int M = 7776;
typedef pair<double, double> ii;
typedef pair<char, pair<int, int> > iii;

int n;
int pr[N], a[N], color[N];
unordered_map<int, int> ump[N];

int find(int u) { return (u == pr[u]) ? u : (pr[u] = find(pr[u])); }


signed main()
{
	// freopen("test.inp", "r", stdin);
	ios_base::sync_with_stdio(0);
    cin.tie(0); 

    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i];
        color[a[i]] = i;
        ump[i][a[i]] = 1;
        pr[i] = i;
    }
    FOR(i, 1, n) {
        int u = find(i);
        int v = find(color[a[i]]);
        if(u != v) {
            if(ump[u].size() > ump[v].size())
                swap(u, v);
            for(auto &it: ump[u]) {
                ump[v][it.fi] = 1;
            }
            ump[u].clear();
            pr[u] = v;
        }
    }
    FOR(i, 1, n / 2) {
        int u = find(i);
        int v = find(n - i + 1);
        if(u != v) {
            if(ump[u].size() > ump[v].size())
                swap(u, v);
            for(auto &it: ump[u]) {
                ump[v][it.fi] = 1;
            }
            ump[u].clear();
            pr[u] = v;
        }
    }

    int res = 0;
    FOR(i, 1, n) if(find(i) == i) {
        res += (ump[i].size() - 1);
    }
    cout << res;
}	
#include <bits/stdc++.h>
using namespace std;

int N;
string s;

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin >> N >> s;
	string t;
	for(int i = 0; i < N; i++)
	{
		t += s[i];
		while(t.size() > 2 && t[t.size() - 1] == 'x' && t[t.size() - 2] == 'o' && t[t.size() - 3] == 'f')
		{
			t.pop_back();
			t.pop_back();
			t.pop_back();
		}
	}
	cout << t.size();

	return 0;
}