#include <bits/stdc++.h>
using namespace std;
int n, letLen[27], dp2[1001], dp3[1001], l;
long long int dp1[1001];
string message = " ";
int main() {
  string x;
  cin >> n >> x;
  message += x;
  for (int i = 0; i < 26; ++i) {
    cin >> letLen[i];
  }
  for (int i = 1; i <= n; ++i) {
    dp3[i] = 1001;
  }
  dp1[0] = 1;
  dp3[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int maxLen = 1001;
    for (int j = 0; j <= maxLen; ++j) {
      maxLen = min(maxLen, letLen[message[i - j] - 'a']);
      if (j + 1 > maxLen || j >= i) break;
      dp1[i] += dp1[i - j - 1];
      dp1[i] %= 1000000007;
      l = max(l, j + 1);
      dp2[i] = max(dp2[i - j - 1], j + 1);
      dp3[i] = min(dp3[i - j - 1] + 1, dp3[i]);
    }
  }
  cout << dp1[n] << " " << l << " " << dp3[n] << '\n';
}
