#include <bits/stdc++.h>
using namespace std;
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
long long Bigmod(long long base, long long power, long long MOD) {
  long long ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
template <typename T>
long long int isLeft(T a, T b, T c) {
  return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);
}
long long ModInverse(long long number, long long MOD) {
  return Bigmod(number, MOD - 2, MOD);
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream second(s);
  second >> sm;
  return sm;
}
string s;
long long int dp[1002];
int vis[20007];
int n;
int a[20007];
int dp2[20007];
int yes2(int p) {
  if (p == n) return 0;
  int &res = dp2[p];
  if (vis[p]) return res;
  vis[p] = 1;
  res = 1000000000;
  int ok[27] = {0};
  for (int i = p; i < n; i++) {
    ok[s[i] - 'a']++;
    int f = 0;
    for (int j = 0; j < 26; j++) {
      if (!ok[j]) continue;
      if ((i - p + 1) > a[j]) {
        f = 1;
        break;
      }
    }
    if (f) {
      break;
    }
    int tp = yes2(i + 1);
    res = min(res, tp + 1);
  }
  return res;
}
int dp1[20007];
int yes1(int p) {
  if (p == n) return 0;
  int &res = dp1[p];
  if (vis[p]) return res;
  vis[p] = 1;
  res = -1000000000;
  int ok[27] = {0};
  for (int i = p; i < n; i++) {
    ok[s[i] - 'a']++;
    int f = 0;
    for (int j = 0; j < 26; j++) {
      if (!ok[j]) continue;
      if ((i - p + 1) > a[j]) {
        f = 1;
        break;
      }
    }
    if (f) {
      break;
    }
    int tp = yes1(i + 1);
    if (tp >= 0) {
      res = max(res, tp);
      res = max(res, (i - p + 1));
    }
  }
  return res;
}
long long int yes(int p) {
  if (p == n) return 1;
  long long int &res = dp[p];
  if (vis[p]) return res;
  vis[p] = 1;
  res = 0;
  int ok[27] = {0};
  for (int i = p; i < n; i++) {
    ok[s[i] - 'a']++;
    int f = 0;
    for (int j = 0; j < 26; j++) {
      if (!ok[j]) continue;
      if ((i - p + 1) > a[j]) {
        f = 1;
        break;
      }
    }
    if (f) {
      break;
    }
    res = (res + yes(i + 1)) % 1000000007;
  }
  return res;
}
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < 26; i++) cin >> a[i];
  memset(vis, 0, sizeof(vis));
  cout << yes(0) << endl;
  memset(vis, 0, sizeof(vis));
  cout << yes1(0) << endl;
  memset(vis, 0, sizeof(vis));
  cout << yes2(0) << endl;
  return 0;
}
