#include <bits/stdc++.h>
using namespace std;
int a[26];
long long dp[1024], ma = 0, mi[1024];
bool isin[26] = {0};
const long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < 26; ++i) cin >> a[i];
  dp[0] = 1, mi[0] = 0;
  for (int i = 1; i <= n; ++i) {
    fill(isin, isin + 26, 0);
    mi[i] = 1e9;
    for (int j = i - 1; j >= 0; --j) {
      isin[s[j] - 'a'] = 1;
      bool fail = 0;
      for (int k = 0; k < 26; ++k)
        if (a[k] < i - j and isin[k]) {
          fail = 1;
          break;
        }
      if (not fail)
        (dp[i] += dp[j]) %= MOD, mi[i] = min(mi[j] + 1, mi[i]),
                                 ma = max(ma, (long long)i - j);
      else
        break;
    }
  }
  cout << dp[n] << '\n';
  cout << ma << '\n';
  cout << mi[n] << '\n';
}
