#include <bits/stdc++.h>
using namespace std;
inline bool is_palindrome(const string& s) {
  return std::equal(s.begin(), s.end(), s.rbegin());
}
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
const int N = 1e3 + 2;
long long dp[N], minml[N], a[26], ans2 = 0;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  memset(dp, 0, sizeof(dp));
  string s;
  int n;
  cin >> n >> s;
  for (long long i = (long long)(0); i < (long long)(26); i++) cin >> a[i];
  dp[0] = 1;
  minml[0] = 0;
  for (long long i = (long long)(1); i < (long long)(n + 1); i++) {
    minml[i] = INF;
    int minm = INF;
    for (long long j = (long long)(i); j >= (long long)(1); j--) {
      int val = s[j - 1] - 'a';
      if (a[val] < minm) minm = a[val];
      if (i - j >= minm) {
        break;
      }
      minml[i] = min(minml[i], 1 + minml[j - 1]);
      ans2 = max(ans2, (i - j + 1));
      dp[i] += dp[j - 1];
      dp[i] %= MOD;
    }
  }
  cout << dp[n] << "\n" << ans2 << "\n" << minml[n];
  return 0;
}
