#include <bits/stdc++.h>
using namespace std;
int freq[26];
string s;
int n;
long long DP1[1002][1002];
int DP2[1002][1002];
int DP3[1002][1002];
long long solve1(int i, int e, int frq[]) {
  if (e == n) return 1;
  if (DP1[i][e] != -1) return DP1[i][e];
  frq[s[e] - 'a']++;
  for (int j = 0; j < 26; j++) {
    if (frq[j] and freq[j] < e - i + 1) {
      for (int j = 0; j < 26; j++) {
        frq[j] = 0;
      }
      frq[s[e] - 'a']++;
      DP1[i][e] = solve1(e, e + 1, frq);
      return DP1[i][e];
    }
  }
  DP1[i][e] = solve1(i, e + 1, frq);
  DP1[i][e] %= 1000000007;
  for (int j = 0; j < 26; j++) {
    frq[j] = 0;
  }
  frq[s[e] - 'a']++;
  if (e) DP1[i][e] += solve1(e, e + 1, frq);
  DP1[i][e] %= 1000000007;
  return DP1[i][e];
}
int solve2(int i, int e, int frq[]) {
  if (e == n) return e - i;
  if (DP2[i][e] != -1) return DP2[i][e];
  frq[s[e] - 'a']++;
  for (int j = 0; j < 26; j++) {
    if (frq[j] and freq[j] < e - i + 1) {
      for (int j = 0; j < 26; j++) {
        frq[j] = 0;
      }
      frq[s[e] - 'a']++;
      DP2[i][e] = solve2(e, e + 1, frq);
      return DP2[i][e];
    }
  }
  DP2[i][e] = max(e - i + 1, solve2(i, e + 1, frq));
  for (int j = 0; j < 26; j++) {
    frq[j] = 0;
  }
  frq[s[e] - 'a']++;
  if (e) DP2[i][e] = max(DP2[i][e], solve2(e, e + 1, frq));
  return DP2[i][e];
}
int solve3(int i, int e, int frq[]) {
  if (e == n) return 1;
  if (DP3[i][e] != -1) return DP3[i][e];
  frq[s[e] - 'a']++;
  for (int j = 0; j < 26; j++) {
    if (frq[j] and freq[j] < e - i + 1) {
      for (int j = 0; j < 26; j++) {
        frq[j] = 0;
      }
      frq[s[e] - 'a']++;
      DP3[i][e] = 1 + solve3(e, e + 1, frq);
      return DP3[i][e];
    }
  }
  DP3[i][e] = solve3(i, e + 1, frq);
  for (int j = 0; j < 26; j++) {
    frq[j] = 0;
  }
  frq[s[e] - 'a']++;
  if (e) DP3[i][e] = min(DP3[i][e], 1 + solve3(e, e + 1, frq));
  return DP3[i][e];
}
int main() {
  cin >> n;
  cin >> s;
  memset(DP1, -1, sizeof DP1);
  memset(DP2, -1, sizeof DP2);
  memset(DP3, -1, sizeof DP3);
  for (int i = 0; i < 26; i++) cin >> freq[i];
  int frq[26];
  for (int i = 0; i < 26; i++) frq[i] = 0;
  cout << solve1(0, 0, frq) << endl;
  for (int i = 0; i < 26; i++) frq[i] = 0;
  cout << solve2(0, 0, frq) << endl;
  for (int i = 0; i < 26; i++) frq[i] = 0;
  cout << solve3(0, 0, frq) << endl;
}
