#include <bits/stdc++.h>
using namespace std;
int c[1003][30];
int dp[1003];
int mini[1003];
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  string second;
  cin >> second;
  int maxi = 0;
  int i;
  int a[30];
  for (i = 0; i < 26; i++) cin >> a[i];
  dp[0] = 1;
  int j;
  c[0][second[0] - 97]++;
  int t;
  int mi;
  int cur;
  mini[0] = 1;
  for (i = 1; i < n; i++) {
    mi = a[second[i] - 97];
    cur = 0;
    dp[i] = 0;
    mini[i] = 10000;
    for (j = i - 1; j >= 0; j--) {
      cur++;
      t = second[j + 1] - 97;
      mi = min(mi, a[t]);
      if (cur <= mi) {
        maxi = max(maxi, cur);
        dp[i] += dp[j];
        dp[i] %= 1000000007;
        mini[i] = min(mini[i], mini[j] + 1);
      } else
        break;
    }
    t = second[0] - 97;
    mi = min(mi, a[t]);
    if (mi >= i + 1) {
      maxi = max(maxi, i + 1);
      dp[i]++;
      dp[i] %= 1000000007;
      mini[i] = 1;
    }
  }
  maxi = max(maxi, 1);
  cout << dp[n - 1] << endl;
  cout << maxi << endl;
  cout << mini[n - 1] << endl;
}
