#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int arr[26];
int dp[1003], dp2[1003];
int main() {
  int i, j, n, mx_len = 0;
  string str;
  cin >> n >> str;
  for (i = 0; i < 26; i++) cin >> arr[i];
  memset(dp2, 0x3f3f3f3f, sizeof(dp2));
  dp[n] = 1;
  dp2[n] = 0;
  for (i = n - 1; i >= 0; i--) {
    int cap = arr[str[i] - 'a'];
    for (j = i + 1; j - i <= cap; j++) {
      dp[i] = (dp[i] + dp[j]) % MOD;
      mx_len = max(mx_len, j - i);
      dp2[i] = min(dp2[i], 1 + dp2[j]);
      if (j == n) break;
      cap = min(cap, arr[str[j] - 'a']);
    }
  }
  cout << dp[0] << endl;
  cout << mx_len << endl;
  cout << dp2[0] << endl;
}
