#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, i, j, k, l, arr[26], max = 1;
  long long int dp[1005], len[1005];
  for (i = 0; i < 1005; i++) dp[i] = 0;
  cin >> a;
  string s;
  cin >> s;
  for (i = 0; i < 26; i++) cin >> arr[i];
  dp[0] = 1;
  dp[1] = 1;
  len[0] = 0;
  for (i = 2; i <= a; i++) {
    int t = 0;
    l = 99999;
    j = i + 1;
    while (j > 1) {
      j--;
      t++;
      if (l > arr[s[j - 1] - 97]) l = arr[s[j - 1] - 97];
      if (l >= t) {
        dp[i] += dp[j - 1];
      } else {
        if (i - j > max) max = i - j;
        len[i] = j;
        break;
      }
      if (j == 1) {
        if (max < i) max = i;
      }
      len[i] = 0;
    }
    dp[i] = dp[i] % 1000000007;
  }
  int ss = 1;
  i = a;
  while (len[i] != 0) {
    i = len[i];
    ss++;
  }
  cout << dp[a] << endl;
  cout << max << endl;
  cout << ss << endl;
  return 0;
}
