#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[3000];
char s[3000];
int a[300];
int xin[3000];
bool judge(int i, int j) {
  int l = j - i + 1;
  for (int k = i; k <= j; k++) {
    if (a[s[k] - 'a'] < l) return false;
  }
  return true;
}
int main() {
  int mix = 1;
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 0; i < 26; i++) scanf("%d", &a[i]);
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  xin[0] = 0;
  for (int i = 1; i <= n; i++) {
    xin[i] = 0x3f3f3f3f;
    for (int j = 1; j <= i; j++) {
      if (judge(i - j + 1, i)) {
        dp[i] = (dp[i] + dp[i - j]) % mod;
        xin[i] = min(xin[i], xin[i - j] + 1);
        if (dp[i - j]) mix = max(mix, j);
      }
    }
  }
  cout << dp[n] << endl;
  cout << mix << endl;
  cout << xin[n] << endl;
  return 0;
}
