#include <bits/stdc++.h>
using namespace std;
int n;
char s[1005];
int a[27];
int dp1[1005], dp2[1005];
int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (int i = 0; i < 26; i++) scanf("%d", a + i);
  dp1[0] = 1;
  dp2[0] = 0;
  int maxx = 0;
  int minn;
  for (int i = 1; s[i]; i++) {
    int limit = a[s[i] - 'a'];
    dp2[i] = minn = 0x3f3f3f3f;
    for (int j = i; j >= 1; j--) {
      limit = min(limit, a[s[j] - 'a']);
      if (i - j + 1 > limit) break;
      dp1[i] = (dp1[i] + dp1[j - 1]) % 1000000007;
      maxx = max(maxx, i - j + 1);
      minn = min(minn, dp2[j - 1]);
    }
    dp2[i] = minn + 1;
  }
  printf("%d\n%d\n%d\n", dp1[n], maxx, dp2[n]);
  return 0;
}
