#include <bits/stdc++.h>
using namespace std;
int maximum = 0;
long long mem[1003];
int n;
int gfreq[26];
string str;
const int MOD = 1000000007;
int dp(int ind) {
  if (mem[ind] != -1) return mem[ind];
  if (ind == n) return 1;
  bool vis[26];
  memset(vis, 0, sizeof vis);
  int res = 0;
  for (int i = ind; i < n; i++) {
    vis[str[i] - 'a'] = 1;
    bool ok = 1;
    for (int j = 0; j < 26; j++) {
      if (vis[j] && i - ind + 1 > gfreq[j]) {
        ok = 0;
        break;
      }
    }
    if (!ok) break;
    maximum = max(maximum, i - ind + 1);
    res = (res % MOD + dp(i + 1) % MOD) % MOD;
  }
  return mem[ind] = res;
}
int dp2(int ind) {
  if (mem[ind] != -1) return mem[ind];
  if (ind == n) return 0;
  bool vis[26];
  memset(vis, 0, sizeof vis);
  int res = 2e9;
  for (int i = ind; i < n; i++) {
    vis[str[i] - 'a'] = 1;
    bool ok = 1;
    for (int j = 0; j < 26; j++) {
      if (vis[j] && i - ind + 1 > gfreq[j]) {
        ok = 0;
        break;
      }
    }
    if (!ok) break;
    res = min(res, 1 + dp2(i + 1));
  }
  return mem[ind] = res;
}
int main() {
  cin >> n;
  cin >> str;
  for (int i = 0; i < 26; i++) {
    cin >> gfreq[i];
  }
  memset(mem, -1, sizeof mem);
  cout << dp(0) << endl;
  cout << maximum << endl;
  memset(mem, -1, sizeof mem);
  cout << dp2(0) << endl;
  return 0;
}
