#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;

long long gcd(long long a, long long b){ return b? gcd(b, a%b) : a; }
long long lcm(long long a, long long b){ return (!a or !b)? 0 : a * b / gcd(a,b); } 
long long  poww(long long  a, long long b){
	long long res = 1;
	while(b){ 
		if(b%2) res = res * a ; 
		a = a * a;  b>>=1;
	} return res;
}

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int rnd(int n){return uniform_int_distribution<int>(0, n-1)(rng);}

template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template<class t,class u>bool mmax(t&a,u b){if(a<b)a=b;return a<b;}
template<class t,class u>bool mmin(t&a,u b){if(b<a)a=b;return b<a;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using li = long long;
using vi = vc<int>;
using ii = pair<int,int>;
// ---- しゃけ ツナマヨ ('-')7

int main(){_

	auto solve=[&](){
		int n; cin>>n;
		string s; cin>>s;
		n++;
		vi v(n); fore(i,0,n)cin>>v[i];
		int k = inf<int>;
		fore(i,0,n-1)k=min(k,abs(v[i+1]-v[i]));
		cout<<k<<ENDL;
		fore(i,0,k){fore(j,0,n)cout<<(v[j]+i)/k<<" ";cout<<ENDL;}
	};
	//int t; cin>>t; while(t--)
	solve();
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N;
string S;

int a[5050], t[5050], c[5050], g[5050];
int sum_A[5050], sum_T[5050], sum_C[5050], sum_G[5050];

int main(void) {

	cin >> N >> S;

	S = '#' + S;

	for (int i = 1; i <= N; i++) {
		if (S[i] == 'A') { a[i] = 1; }
		else if (S[i] == 'T') { t[i] = 1; }
		else if (S[i] == 'C') { c[i] = 1; }
		else if (S[i] == 'G') { g[i] = 1; }
	}

	for (int i = 1; i <= N; i++) {
		sum_A[i] = sum_A[i - 1] + a[i];
		sum_T[i] = sum_T[i - 1] + t[i];
		sum_C[i] = sum_C[i - 1] + c[i];
		sum_G[i] = sum_G[i - 1] + g[i];
	}


	int ans = 0;

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if ((sum_A[j] - sum_A[i - 1] == sum_T[j] - sum_T[i - 1]) && (sum_G[j] - sum_G[i - 1] == sum_C[j] - sum_C[i - 1])) { ans++; }
		}
	}

	cout << ans << endl;

	return 0;
}