#include <bits/stdc++.h>
using namespace std;
unsigned int dp[(int)1e3 + 7], mn[(int)1e3 + 7], n;
int a[(int)1e3 + 7], b[26], ml = 0;
char aa[(int)1e3 + 7];
void dpi() {
  dp[0] = 1;
  mn[0] = 1;
  ml = 1;
  for (int i = 1; i < n; i++) {
    int mm = a[i];
    dp[i] = dp[i - 1];
    mn[i] = mn[i - 1] + 1;
    for (int j = i - 1; j > 0; j--) {
      mm = min(a[j], mm);
      if (mm >= i - j + 1) {
        dp[i] += dp[j - 1];
        dp[i] %= (int)1e9 + 7;
        mn[i] = min(mn[j - 1] + 1, mn[i]);
        ml = max(ml, i - j + 1);
      }
    }
    mm = min(a[0], mm);
    if (mm >= i + 1) {
      dp[i]++;
      mn[i] = 1;
      ml = max(ml, i + 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%s", aa);
  for (int i = 0; i < 26; i++) scanf("%d", &b[i]);
  for (int i = 0; i < n; i++) a[i] = b[aa[i] - 'a'];
  dpi();
  printf("%d\n%d\n%d", dp[n - 1], ml, mn[n - 1]);
  return 0;
}
