#include <bits/stdc++.h>
using namespace std;
int n, a[26], dp[1010], mins[1010];
char s[1010];
void solve() {
  int mxle = 0;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int lim = n;
    mins[i + 1] = n;
    for (int j = i; j >= 0; j--) {
      lim = min(lim, a[s[j] - 'a']);
      if (i - j + 1 > lim) break;
      mxle = max(i - j + 1, mxle);
      dp[i + 1] += dp[j];
      if (dp[i + 1] >= (int)1e9 + 7) dp[i + 1] -= (int)1e9 + 7;
      mins[i + 1] = min(mins[i + 1], mins[j] + 1);
    }
  }
  cout << dp[n] << "\n";
  cout << mxle << "\n";
  cout << mins[n] << "\n";
}
int main() {
  cin >> n >> s;
  for (int i = 0; i < 26; i++) cin >> a[i];
  solve();
  return 0;
}
