#include <bits/stdc++.h>
using namespace std;
using namespace std;
void Draganov47() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int MOD = 1e9 + 7;
int get_dp1(string s, vector<int> rules) {
  vector<int> dp(s.size() + 1);
  dp[0] = 1;
  for (int i = 0; i < s.size(); i++) {
    int mn = 1e9;
    for (int j = i + 1; j <= s.size(); j++) {
      int len = j - i;
      mn = min(mn, rules[s[j - 1] - 'a']);
      if (len > mn) break;
      dp[j] += dp[i];
      dp[j] %= MOD;
    }
  }
  return (dp[s.size()] % MOD);
}
int get_dp2(string s, vector<int> rules) {
  int best = 1;
  for (int i = 0; i < s.size(); i++) {
    int mn = 1e9;
    for (int j = i + 1; j <= s.size(); j++) {
      int len = j - i;
      mn = min(mn, rules[s[j - 1] - 'a']);
      if (len > mn) break;
      best = max(best, len);
    }
  }
  return best;
}
int get_dp3(string s, vector<int> rules) {
  vector<int> dp(s.size() + 1, 1e9);
  dp[0] = 0;
  for (int i = 0; i < s.size(); i++) {
    int mn = 1e9;
    for (int j = i + 1; j <= s.size(); j++) {
      int len = j - i;
      mn = min(mn, rules[s[j - 1] - 'a']);
      if (len > mn) break;
      dp[j] = min(dp[j], dp[i] + 1);
    }
  }
  return dp[s.size()];
}
int main() {
  Draganov47();
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> rules(26);
  for (int i = 0; i < 26; i++) cin >> rules[i];
  int ans1 = get_dp1(s, rules);
  int ans2 = get_dp2(s, rules);
  int ans3 = get_dp3(s, rules);
  cout << ans1 << endl << ans2 << endl << ans3;
  return 0;
}
