#include <bits/stdc++.h>
using namespace std;
long long d, i, j, n, mx, k, c[1009], b[1009], a[1009];
string s;
int main() {
  cin >> n >> s;
  for (i = 0; i < 26; i++) cin >> c[i];
  a[0] = 1;
  mx = 1000000007;
  for (i = 1; i <= n; i++) {
    d = 0;
    b[i] = n + 1;
    for (j = i - 1; j >= 0; j--) {
      d = max(d, i - c[s[j] - 'a']);
      if (d > j) break;
      a[i] = (a[i] + a[j]) % mx;
      b[i] = min(b[i], b[j] + 1);
      k = max(k, i - j);
    }
  }
  cout << a[n] << endl << k << endl << b[n];
}
