#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, mod = 1000000007, a[26], f[1000] = {}, l[1000] = {}, g[1000];
  string s;
  cin >> n >> s;
  for (int i = 0; i < 26; i++) cin >> a[i];
  f[0] = l[0] = g[0] = 1;
  for (int i = 1; i < n; i++) {
    long long z = i, b[26] = {};
    while (z >= 0) {
      b[s[z] - 'a'] = 1;
      long long flag = 1;
      for (int j = 0; j < 26; j++)
        if (b[j] && a[j] < i - z + 1) {
          flag = 0;
          break;
        }
      if (!flag) break;
      z--;
    }
    g[i] = i + 1;
    for (long long j = z + 1; j <= i; j++) {
      f[i] = (f[i] + (j ? f[j - 1] : 1)) % mod;
      l[i] = max({l[i], i - j + 1, (j ? l[j - 1] : 0)});
      g[i] = min(g[i], 1 + (j ? g[j - 1] : 0));
    }
  }
  cout << f[n - 1] << endl << l[n - 1] << endl << g[n - 1];
}
