#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
const long long N = 1e3 + 5;
long long dp[N], dp2[N];
bool check(vector<long long> fr, vector<long long> a, long long len) {
  for (long long i = 0; i < 26; i++) {
    if (fr[i] == 0) continue;
    if (a[i] < len) return false;
  }
  return true;
}
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  s = '$' + s;
  vector<long long> a(26);
  for (long long i = 0; i < 26; i++) {
    cin >> a[i];
  }
  memset(dp, 0, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  dp[0] = 1;
  long long minni = 1e18, maxxi = 1;
  for (long long i = 1; i <= n; i++) {
    vector<long long> fr(26, 0);
    for (long long j = i; j >= 1; j--) {
      if (j != 0) fr[s[j] - 'a']++;
      if (check(fr, a, i - j + 1)) {
        maxxi = max(maxxi, i - j + 1);
        dp[i] = (dp[i] + dp[j - 1]) % mod;
        dp2[i] = dp2[j - 1] + 1;
      }
    }
  }
  cout << dp[n] << "\n" << maxxi << "\n" << dp2[n] << "\n";
}
int32_t main() {
  long long t = 1;
  for (long long T = 1; T <= t; T++) {
    solve();
  }
}
