#include <bits/stdc++.h>
using namespace std;
long long GI(long long &a) { return scanf("%I64d", &a); }
long long n, i, j, k, tmp, m;
vector<long long> vt;
long long a[30];
long long b[30];
vector<long long> v1, v2, v3;
char s[1010];
int32_t main() {
  GI(n);
  scanf("%s", s);
  for ((i) = 0; (i) < (long long)(26); ++i) GI(a[i]);
  long long f[1010] = {0}, c[1010] = {0};
  long long lg = 1;
  f[0] = 1;
  c[0] = 0;
  for (long long i = (long long)1, _b = n; i <= _b; ++i) {
    long long cur;
    c[i] = 10000;
    f[i] = 0;
    long long lim = 1000;
    for (long long l = (long long)1, _b = i; l <= _b; ++l) {
      cur = i - l;
      lim = (lim < a[s[cur] - 'a'] ? lim : a[s[cur] - 'a']);
      if (l > lim) break;
      lg = (lg > l ? lg : l);
      f[i] = (f[i] + f[i - l]) % 1000000007;
      c[i] = (c[i] < c[i - l] + 1 ? c[i] : c[i - l] + 1);
    }
  }
  printf("%d\n", f[n]);
  printf("%d\n", lg);
  printf("%d\n", c[n]);
}
