#include <bits/stdc++.h>
using namespace std;
const int N6 = 1e6 + 6;
const int N9 = 1e9 + 7;
const long long N = 111111;
const long long INF = (long long)1e18 + 100;
const long long mod = 1e9 + 7;
const long long BLOCK = 322;
int n, z[28], dp[1111], dp2[1111], l;
string s;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(NULL);
  cin >> n;
  cin >> s;
  for (__typeof(26) i = 0; i < 26; ++i) cin >> z[i];
  dp[0] = 1;
  for (__typeof(n) i = 1; i <= n; ++i) {
    int f = 0;
    dp2[i] = n;
    for (int j = i - 1; j >= 0; --j) {
      f = max(f, i - z[s[j] - 97]);
      if (f > j) continue;
      dp[i] = (dp[i] + dp[j]) % mod;
      dp2[i] = min(dp2[i], 1 + dp2[j]);
      l = max(l, i - j);
    }
  }
  cout << dp[n] << '\n' << l << '\n' << dp2[n];
  return 0;
}
