#include <bits/stdc++.h>
using namespace std;
long long t, d, ct, q, ans, l, m, r, n, mx, mn, i, j, k, x, y, z, s;
char ch;
string ss = "", str = "";
long long a[200003], b[200003];
long long pref[200003];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  s = k = d = l = mx = m = mn = r = q = i = j = z = x = y = ct = ans = 0;
  for (i = 0; i < 26; i++) cin >> a[i];
  cin >> ss;
  n = ss.length();
  pref[1] = a[ss[0] - 'a'];
  for (i = 1; i < n; i++) pref[i + 1] = pref[i] + a[ss[i] - 'a'];
  vector<long long> v[26];
  for (i = 0; i < n; i++) v[ss[i] - 'a'].push_back(i + 1);
  for (i = 0; i < 26; i++) {
    m = v[i].size();
    if (m <= 1) continue;
    y = 0;
    vector<long long> diff;
    for (auto h : v[i]) diff.push_back(pref[h - 1]);
    map<long long, long long> mp;
    for (j = 0; j < diff.size(); j++) {
      ans += mp[diff[j] - a[i]];
      mp[diff[j]]++;
    }
  }
  cout << ans;
  return 0;
}
