#include <bits/stdc++.h>
using namespace std;
const int MXN = 1005;
const int MOD = 1000000007;
int N, st[MXN], limit[26];
int dp[MXN];
char s[MXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> N;
  cin >> (s + 1);
  for (int i = 0; i < (26); i++) cin >> limit[i];
  for (int i = (1); i <= (N); i++) {
    int lim = MXN;
    for (int j = i; j >= 1; j--) {
      lim = min(lim, limit[s[j] - 'a']);
      if (lim >= i - j + 1) {
        st[i] = j;
      } else {
        break;
      }
    }
  }
  int ans1 = 0;
  int ans2 = 0;
  int ans3 = 0;
  dp[0] = 1;
  for (int i = (1); i <= (N); i++) {
    dp[i] = 0;
    for (int j = (st[i]); j <= (i); j++) {
      dp[i] += dp[j - 1];
      if (dp[i] >= MOD) dp[i] -= MOD;
    }
  }
  ans1 = dp[N];
  for (int i = (1); i <= (N); i++) ans2 = max(ans2, i - st[i] + 1);
  for (int i = N; i > 0; i = st[i] - 1) ans3++;
  cout << ans1 << endl;
  cout << ans2 << endl;
  cout << ans3 << endl;
  return 0;
}
