#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int d[1010], c[1010], a[1010];
long long f[1010][1010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> s;
  for (int i = 1; i <= 26; i++) cin >> d[i];
  for (int i = 1; i <= n; i++) a[i] = s[i - 1] - 'a' + 1;
  f[0][0] = 1;
  int res2 = 0;
  for (int i = 1; i <= n; i++) {
    int temp = 1000000007;
    for (int j = i; j >= 1; j--) {
      temp = min(temp, d[a[j]]);
      if (i - j + 1 > temp) break;
      res2 = max(res2, i - j + 1);
      for (int k = 0; k <= j - 1; k++)
        f[i][k + 1] = (f[i][k + 1] + f[j - 1][k]) % 1000000007;
    }
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) res = (res + f[n][i]) % 1000000007;
  cout << res << " " << res2 << " ";
  for (int i = 1; i <= n; i++)
    if (f[n][i] > 0) {
      res = i;
      break;
    }
  cout << res;
}
