#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, len = 0;
  cin >> n;
  string s;
  cin >> s;
  vector<long long> a(26);
  for (i = 0; i < 26; i++) cin >> a[i];
  long long dp[n], m[n], l[n];
  dp[0] = 1;
  m[0] = 1;
  l[0] = 1;
  for (i = 1; i < n; i++) {
    dp[i] = 0;
    m[i] = 1e18;
    l[i] = 1;
    long long temp = 1e18, var;
    for (j = 1; j <= a[s[i] - 'a'] && j <= i + 1; j++) {
      var = a[s[i - j + 1] - 'a'];
      temp = min(temp, var);
      if (temp < j) break;
      if (j == i + 1) {
        dp[i] += 1;
        dp[i] %= 1000000007;
        l[i] = max(l[i], j);
        m[i] = min(m[i], (long long)1);
      } else {
        dp[i] += dp[i - j];
        dp[i] %= 1000000007;
        l[i] = max(l[i - j], max(l[i], j));
        m[i] = min(m[i], m[i - j] + 1);
      }
    }
  }
  cout << dp[n - 1] << endl;
  cout << l[n - 1] << endl;
  cout << m[n - 1];
  return 0;
}
