#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
string s;
int mLen[30];
bool ok(int l, int r) {
  for (int i = (l); i < (r); ++i) {
    if (r - l > mLen[s[i] - 'a']) {
      return false;
    }
  }
  return true;
}
int dp[2000];
int dp2[2000];
int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  cin >> s;
  for (int i = (0); i < (26); ++i) {
    cin >> mLen[i];
  }
  for (int i = (0); i < (n + 1); ++i) {
    dp2[i] = (1000000000);
  }
  dp[0] = 1;
  dp2[0] = 0;
  int maxL = 0;
  for (int i = (1); i < (n + 1); ++i) {
    int l = i - 1;
    while (l >= 0 && ok(l, i)) {
      maxL = max(maxL, i - l);
      dp[i] += dp[l];
      dp[i] %= MOD;
      dp2[i] = min(dp2[i], dp2[l] + 1);
      l--;
    }
  }
  cout << dp[n] % MOD << endl;
  cout << maxL << endl;
  cout << dp2[n] << endl;
  return 0;
}
