//#include <atcoder/all>
#include <bits/stdc++.h>
//using namespace atcoder;
using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}


void solve()
{
  ll N; cin >> N;
  vector<int> atc(5050, 0), cgc(5050, 0);
  string s; cin >> s;
  int at = 0, cg = 0;
  ll ans = 0;
  rep(i, N) {
    switch(s[i]) {
    case 'A':
      atc[i + 1] = atc[i] + 1;
      cgc[i + 1] = cgc[i];
      break;
    case 'T':
      atc[i + 1] = atc[i] - 1;
            cgc[i + 1] = cgc[i];
      break;
    case 'C':
      atc[i + 1] = atc[i];
      cgc[i + 1] = cgc[i] + 1;
      break;
    case 'G':
      atc[i + 1] = atc[i];
      cgc[i + 1] = cgc[i] - 1;
      break;
    }
  }

    
  
  rep(i, N) {
    for(ll j = i + 1; j <= N; j++) {
      if(atc[i] == atc[j] && cgc[i] == cgc[j]) ans++;
    }
  }
  
  cout << ans << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrep1(i, n) for (int i = n; i >= 1; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define eb emplace_back
#define fi first
#define se second
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef long long int ll;
typedef pair<int, int> P;
// typedef modint1000000007 mint;

void speedUpIO() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
}

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/*--------------------------------------------------*/
const int INF = 1e9;
// const ll INF = 1e18;
const int MAX = 1e5;

int h, w, a, b;
V<int> dh = {0, 1};
V<int> dw = {1, 0};

int ans = 0;

void dfs(VV<bool> used, int maia) {
    if (maia == a) {
        ans++;
        return;
    }
    rep(hi, h) {
        rep(wi, w) {
            if (used[hi][wi]) continue;
            used[hi][wi] = true;
            rep(i, 2) {
                int nh = hi + dh[i];
                int nw = wi + dw[i];
                if (nh < 0 || h <= nh) continue;
                if (nw < 0 || w <= nw) continue;
                if (used[nh][nw]) continue;
                used[nh][nw] = true;
                dfs(used, maia + 1);
                used[nh][nw] = false;
            }
        }
    }
}

void solve() {
    cin >> h >> w >> a >> b;
    // a: 2 * 1, b: 1 * 1;
    VV<bool> used(h, V<bool>(w));
    dfs(used, 0);
    cout << ans << "\n";
}

int main() {
    speedUpIO();
    solve();
    return 0;
}
