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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fp(i,a,b) for(int i=a ; i<b ; i++)
#define fn(i,a,b) for(int i=a ; i>=b ; i--)
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int M=1e5+5;
const int INF=1e9;
const int MOD=1e9+7;

void go(){
	int n; cin >> n;
	string s; cin >> s;
	stack <char> st;
	vector <char> v;
	
	fp(i,0,n){
		if (st.size() < 2 or s[i] != 'x') st.push(s[i]);
		else {
			char x = st.top(); st.pop();
			char y = st.top();
			
			if (x == 'o' and y == 'f') st.pop();
			else{
				st.push(x);
				st.push(s[i]);
			}
		}
	}
	
	cout << st.size() << "\n";
}

int main(){

	fastio;
	go();

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define pob pop_back()
#define ms0(s) memset(s,0,sizeof s)
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define prq priority_queue<ll>  //max-heap
#define psq priority_queue<ll,vector<ll>,greater<ll>>  //min-heap
#define m_p make_pair
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define setbit(n) __builtin_popcountll(n)
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
//   cin>>t;
	while (t--)
	{
		ll i, j, k, n, m, ans = 0;
		cin >> n;
		string s;
		cin >> s;
		for (i = 0; i < n; i++)
		{
			map<char, ll>mc;
			for (j = i; j < n; j++)
			{
				mc[s[j]]++;
				if (mc['A'] == mc['T'] && mc['C'] == mc['G'])
					ans++;
			}
		}
		cout << ans;
	}
	return 0;
}