#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int m = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0;
  cin >> n;
  string s;
  cin >> s;
  vector<int> alp(26);
  for (int i = 0; i < 26; i++) cin >> alp[i];
  int dp[3][1042] = {0};
  dp[0][0] = 1;
  dp[1][0] = 0;
  dp[2][0] = 0;
  for (int i = 1; i < 1042; i++) dp[2][i] = 1e9 + 42;
  for (int i = 1; i <= n; i++) {
    int x = i - 1;
    int l = i - alp[s[x] - 'a'];
    while (x >= l) {
      dp[0][i] = (dp[0][i] + dp[0][x]) % m;
      dp[1][i] = max(max(dp[1][i], i - x), dp[1][x]);
      dp[2][i] = min(dp[2][i], dp[2][x] + 1);
      x--;
      l = max(l, i - alp[s[x] - 'a']);
    }
  }
  for (int ans = 0; ans < 3; ans++) cout << dp[ans][n] << endl;
  return 0;
}
