#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1e18;
void rd(int &x) { scanf("%d", &x); }
void rd(long long &x) { scanf("%lld", &x); }
void rd(double &x) { scanf("%lf", &x); }
void rd(int &x, int &y) { scanf("%d%d", &x, &y); }
void rd(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void rd(int &x, int &y, int &z) { scanf("%d%d%d", &x, &y, &z); }
void rd(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void rd(double &x, double &y) { scanf("%lf%lf", &x, &y); }
void rd(double &x, double &y, double &z) { scanf("%lf%lf%lf", &x, &y, &z); }
void rd(char *s) { scanf("%s", s); }
void rd(char &s) { scanf("%c", &s); }
void rd(string &s) { getline(cin, s); }
void pf(int x) { printf("%d\n", x); }
void pf(int x, int y) { printf("%d %d\n", x, y); }
void pf(long long x) { printf("%lld\n", x); }
void pf(char x) { printf("%c\n", x); }
void pf(char *x) { printf("%s\n", x); }
void pf(string x) { cout << x << endl; }
int main() {
  int n, ara[30], dp[1005] = {0};
  string s;
  cin >> n;
  cin >> s;
  for (int i = 1; i <= (26); i++) cin >> ara[i];
  dp[0] = 1;
  int ans2 = 0;
  for (int i = 1; i <= (n); i++) {
    int l = 0;
    for (int j = i - 1; j >= 0; j--) {
      l = max(l, i - ara[s[j] - 'a' + 1]);
      if (j >= l) {
        dp[i] = (dp[i] % 1000000007 + dp[j] % 1000000007) % 1000000007;
        ans2 = max(ans2, i - j);
      } else
        break;
    }
    dp[i] = dp[i] % 1000000007;
  }
  cout << dp[n] << "\n" << ans2 << "\n";
  int ans3 = 1, sum = 10000, node = 0;
  for (int i = 0; i < (n); i++) {
    sum = min(sum, ara[s[i] - 'a' + 1]);
    if (node >= sum) {
      ans3++;
      sum = ara[s[i] - 'a' + 1];
      node = 1;
    } else
      node++;
  }
  cout << ans3;
}
