#include <bits/stdc++.h>
using namespace std;
int a[27];
int dp[123456];
int sum[1234][26];
int mn[1234];
int mx[1234];
int main() {
  const int MOD = 1000000007;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < 26; ++i) cin >> a[i];
  s = "0" + s;
  for (int i = 1; i < s.size(); ++i) {
    for (int j = 0; j < 26; ++j) sum[i][j] = sum[i - 1][j];
    sum[i][s[i] - 'a']++;
  }
  dp[0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    for (int j = 0; j < i; ++j) {
      vector<int> chisla(26);
      for (int k = 0; k < 26; ++k) chisla[k] = sum[i][k] - sum[j][k];
      bool ok = 1;
      for (int k = 0; k < 26; ++k) {
        if (chisla[k] && a[k] < i - j) {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (mn[i] == 0)
          mn[i] = mn[j] + 1;
        else
          mn[i] = min(mn[i], mn[j] + 1);
        mx[i] = max(max(mx[i], i - j), mx[j]);
        dp[i] += dp[j];
        if (dp[i] >= MOD) dp[i] -= MOD;
      }
    }
  }
  int m = s.size() - 1;
  cout << dp[m] << " " << mx[m] << " " << mn[m];
  return 0;
}
