#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, l, j, maks, a[27];
long long dp[1010], dp2[1010];
string s = " ", s2;
int main() {
  cin >> n;
  cin >> s;
  for (int i = 0; i < 26; i++) cin >> a[i];
  dp[0] = 1;
  dp2[0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = 0;
    dp2[i] = INT_MAX;
  }
  maks = 1;
  for (int i = 1; i <= n; i++) {
    l = 0;
    j = i - 1;
    while (j >= 0) {
      l = max(l, i - a[s[j] - 'a']);
      if (l > j) break;
      dp[i] = (dp[i] + dp[j]) % mod;
      maks = max(maks, i - j);
      dp2[i] = min(dp2[i], dp2[j] + 1);
      j--;
    }
  }
  cout << dp[n] << "\n" << maks << "\n" << dp2[n];
  return 0;
}
