#include <bits/stdc++.h>
using namespace std;
const int ALNUM = 26;
const int MAXN = 100005;
int score[ALNUM];
char str[MAXN];
long long sum[MAXN];
long long ans;
vector<int> vec[ALNUM];
map<long long, long long> mp;
void Init();
void Cal(int);
int main() {
  while (scanf("%d", &score[0]) != EOF) {
    for (int i = 1; i < ALNUM; i++) scanf("%d", &score[i]);
    scanf("%s", str);
    Init();
    for (int i = 0; i < ALNUM; i++) Cal(i);
    cout << ans << endl;
  }
  return 0;
}
void Init() {
  ans = 0;
  for (int i = 0; i < ALNUM; i++) vec[i].clear();
  sum[0] = score[str[0] - 'a'];
  for (int i = 1; str[i] != '\0'; i++)
    sum[i] = sum[i - 1] + score[str[i] - 'a'];
  for (int i = 0; str[i] != '\0'; i++) vec[str[i] - 'a'].push_back(i);
  return;
}
void Cal(int n) {
  mp.clear();
  int siz = vec[n].size();
  for (int i = 0; i < siz; i++) {
    long long val = sum[vec[n][i]];
    if (mp.count(val - score[n])) ans += mp[val - score[n]];
    if (mp.count(val))
      mp[val]++;
    else
      mp[val] = 1;
  }
  return;
}
