#include <bits/stdc++.h>   using namespace std;   int n, m, a, b, mas[30], summ[100005];   long long sum, countt;   string s;   map<pair<char, long long>, int> matr;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     for (int i = 0; i < 26; ++i) cin >> mas[i];     cin >> s;     for (int i = 0; i < s.size(); ++i) {       if (matr.count(make_pair(s[i], sum))) countt += matr[make_pair(s[i], sum)];       sum += mas[s[i] -  a ];       matr[make_pair(s[i], sum)]++;     }     cout << countt;     return 0;   }   