#include <bits/stdc++.h>
using namespace std;
int n;
char a[1<<17];
int cnt[2048];
long long ans;
int parity[16];
int main() {
int i,j,current_mask;
scanf("%d", &n);
scanf("%s", a+1);
++cnt[0];
for(i=1;i<=n;i++) {
parity[a[i]-'0']^=1;
current_mask=0;
for(j=0;j<10;j++) if(parity[j]) current_mask|=(1<<j);
ans+=cnt[current_mask];
for(j=0;j<10;j++) ans+=cnt[current_mask^(1<<j)];
++cnt[current_mask];
}
printf("%lld\n", ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG47CmNoYXIgYVsxPDwxN107CmludCBjbnRbMjA0OF07CmxvbmcgbG9uZyBhbnM7CmludCBwYXJpdHlbMTZdOwoKaW50IG1haW4oKSB7CglpbnQgaSxqLGN1cnJlbnRfbWFzazsKCQoJc2NhbmYoIiVkIiwgJm4pOwoJc2NhbmYoIiVzIiwgYSsxKTsKCQoJKytjbnRbMF07Cglmb3IoaT0xO2k8PW47aSsrKSB7CgkJcGFyaXR5W2FbaV0tJzAnXV49MTsKCQljdXJyZW50X21hc2s9MDsKCQlmb3Ioaj0wO2o8MTA7aisrKSBpZihwYXJpdHlbal0pIGN1cnJlbnRfbWFza3w9KDE8PGopOwoJCWFucys9Y250W2N1cnJlbnRfbWFza107CgkJZm9yKGo9MDtqPDEwO2orKykgYW5zKz1jbnRbY3VycmVudF9tYXNrXigxPDxqKV07CgkJKytjbnRbY3VycmVudF9tYXNrXTsKCX0KCQoJcHJpbnRmKCIlbGxkXG4iLCBhbnMpOwoJCglyZXR1cm4gMDsKfQo=