#include <bits/stdc++.h>
using namespace std;
char s[1005];
int a[30];
int dp[1005], num[1005];
int main(void) {
  num[0] = 0;
  for (int i = 1; i < 1005; i++) {
    num[i] = 1 << 30;
  }
  int N;
  scanf("%d%s", &N, s + 1);
  for (int i = 0; i < 26; i++) {
    scanf("%d", a + i);
  }
  int len = 0;
  dp[0] = 1;
  for (int i = 1; i <= N; i++) {
    bool check = true;
    int M = N;
    for (int j = i; j > -1; j--) {
      M = min(M, a[s[j] - 'a']);
      check = check && (i - j + 1 <= M);
      if (!check) {
        break;
      }
      len = max(len, i - j + 1);
      dp[i] += dp[j - 1];
      dp[i] %= 1000000007;
      num[i] = min(num[i], num[j - 1] + 1);
    }
  }
  printf("%d\n%d\n%d\n", dp[N], len, num[N]);
  return 0;
}
