#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005, md = 1e9 + 7;
int flag[maxn], mn[maxn];
int main() {
  ;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, i, j;
  string s;
  cin >> n >> s;
  int a[27];
  for (i = 0; i < 26; i++) cin >> a[i];
  int l = 1;
  flag[n] = 1;
  mn[n] = 0;
  for (i = n - 1; i >= 0; i--) {
    int mx = maxn;
    mn[i] = maxn;
    for (j = i; j < n; j++) {
      mx = min(mx, a[s[j] - 'a']);
      if (mx < j - i + 1) break;
      flag[i] = (flag[i] + flag[j + 1]) % md;
      mn[i] = min(mn[i], 1 + mn[j + 1]);
      l = max(l, j - i + 1);
    }
  }
  cout << flag[0] << endl << l << endl << mn[0];
  return 0;
}
