#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int inf = 10000;
int n;
string s;
int m[26];
long long dp[1005];
int minstr[1005] = {inf};
int maxlen;
int main() {
  memset(minstr, inf, sizeof(minstr));
  cin >> n;
  cin >> s;
  for (int i = 0; i < 26; i++) cin >> m[i];
  dp[0] = dp[1] = 1;
  minstr[0] = 0;
  minstr[1] = 1;
  maxlen = 1;
  for (int i = 2; i <= n; i++) {
    int span = m[s[i - 1] - 'a'];
    for (int j = 0; j + 1 <= min(m[s[i - 1] - 'a'], i) && span >= j + 1; j++) {
      minstr[i] = min(minstr[i], 1 + minstr[i - j - 1]);
      span = min(span, m[s[i - j - 2] - 'a']);
      dp[i] = (dp[i] + dp[i - j - 1]) % mod;
      maxlen = max(maxlen, j + 1);
    }
  }
  cout << dp[n] << endl;
  cout << maxlen << endl;
  cout << minstr[n] << endl;
}
