#include <bits/stdc++.h>
using namespace std;
int ma[26];
int main() {
  int n;
  cin >> n;
  string st;
  cin >> st;
  for (int i = 0; i < 26; i++) {
    cin >> ma[i];
  }
  int DP[n + 1];
  int AC[n + 1];
  for (int i = 0; i <= n; i++) {
    AC[i] = DP[i] = 0;
  }
  DP[0] = 1;
  int may = 0;
  for (int i = 1; i <= n; i++) {
    int left = 0;
    AC[i] = n;
    for (int j = i - 1; j >= 0; j--) {
      left = max(left, i - ma[st[j] - 'a']);
      if (left <= j) {
        may = max(may, i - j);
        DP[i] = (DP[i] + DP[j]) % 1000000007;
        AC[i] = min(AC[i], AC[j] + 1);
      }
    }
  }
  cout << DP[n] << endl << may << endl << AC[n] << endl;
  return 0;
}
