#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
const int infi = 1e9;
const long long Linfi = 1e18;
const long long MOD = 1000000007;
const int c1 = 31;
const int c2 = 37;
long long f[1000005], g[1000005], h[1000005];
int a[30];
string s;
int n;
bool check(int l, int r) {
  for (int i = l; i <= r; i++) {
    if (a[s[i - 1] - 97] < r - l + 1) return false;
  }
  return true;
}
void solve() {
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  memset(h, 0, sizeof(h));
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    h[i] = infi;
    for (int j = 1; j <= i; j++) {
      if (check(j, i)) {
        f[i] = (f[i] + f[j - 1]) % MOD;
        g[i] = max(g[i], max(g[j - 1], (long long)(i - j + 1)));
        h[i] = min(h[i], h[j - 1] + 1);
      }
    }
  }
  cout << f[n] << "\n" << g[n] << "\n" << h[n] << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int sotest = 1;
  while (sotest--) {
    cin >> n >> s;
    for (int i = 0; i < 26; i++) cin >> a[i];
    solve();
  }
  return 0;
}
