#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 5050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\n\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int sum[4][N];
char c[] = {'A', 'T', 'C', 'G'};
int n;
char s[N];
bool check1(int l, int r)
{
    int tmp1 = sum[0][r] - sum[0][l - 1];
    int tmp2 = sum[1][r] - sum[1][l - 1];
    int tmp3 = sum[2][r] - sum[2][l - 1];
    int tmp4 = sum[3][r] - sum[3][l - 1];
    if (tmp1 > 0 && tmp2 > 0 && tmp3 > 0 && tmp4 > 0 && tmp1 == tmp2 && tmp3 == tmp4)
        return 1;
    if (tmp1 + tmp2 == 0 && tmp3 > 0 && tmp4 > 0 && tmp3 == tmp4)
        return 1;
    if (tmp1 > 0 && tmp2 > 0 && tmp3 + tmp4 == 0 && tmp1 == tmp2)
        return 1;
    return 0;
}

inline void solve()
{
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < 4; ++j)
            sum[j][i] = sum[j][i - 1] + (s[i] == c[j]);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            if (check1(i, j))
                ans++;
        }
    }
    printf("%d\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
    {
        solve();
        // if (Test)
        //     putchar('\n');
    }
    TIME__END = clock();
    program_end();
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline int read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg int res=0;
	while(!isdigit(ch))f|=(ch=='-'),ch=getchar();
	while(isdigit(ch))res=10*res+(ch^'0'),ch=getchar();
	return f?-res:res;
}
inline ll readll(void){
	reg bool f=false;
	reg char ch=getchar();
	reg ll res=0;
	while(!isdigit(ch))f|=(ch=='-'),ch=getchar();
	while(isdigit(ch))res=10ll*res+(ch^'0'),ch=getchar();
	return f?-res:res;
}

const int MAXN=50+5;

int n;
ll x;
ll a[MAXN];
map<ll,ll> f,g;

int main(void){
	n=read(),x=readll();
	for(reg int i=1;i<=n;++i)
		a[n-i+1]=readll();
	ll x0=x/a[1]*a[1];
	f[x0]=1;
	if(x0!=x)
		f[x0+a[1]]=1;
	for(reg int i=2;i<=n;++i){
		g.clear();
		reg ll Max=a[i-1]/a[i];
		for(auto it:f){
			reg ll d=x-it.first,m=d/a[i];
			ll y=it.first+m*a[i];
			if(abs(m)<Max)
				g[y]+=it.second;
			if(y!=x&&abs(m)+1<Max)
				g[y+a[i]*(d/abs(d))]+=it.second;
		}
		swap(f,g);
	}
	printf("%lld\n",f[x]);
	return 0;
}