#include <bits/stdc++.h>
using namespace std;
int n, arr[26], tarr[26], max_val[1004], min_val[1004], dp[1004][26],
    mod = 1000000007;
long long int total[1004];
string val;
void make_dp() {
  for (int i = 0; i < n; i++) {
    if (i == 0)
      dp[i][val[i] - 'a'] = 1;
    else {
      for (int j = 0; j < 26; j++) {
        if (j == val[i] - 'a')
          dp[i][j] = dp[i - 1][j] + 1;
        else
          dp[i][j] = dp[i - 1][j];
      }
    }
  }
}
bool check1(int ss) {
  bool y = true;
  for (int i = 0; i < 26; i++) {
    if (dp[ss - 1][i] > 0 && arr[i] < ss) {
      y = false;
      break;
    }
  }
  return y;
}
bool check2(int ss) {
  bool y = true;
  for (int i = 0; i < 26; i++) {
    if (tarr[i] > 0 && arr[i] < ss) {
      y = false;
      break;
    }
  }
  return y;
}
void give_ans() {
  max_val[0] = 1;
  min_val[0] = 1;
  total[0] = 1;
  for (int i = 1; i < n; i++) {
    memset(tarr, 0, sizeof(tarr));
    long long int sum = 0;
    for (int j = i; j >= 0; j--) {
      if (j == i && check1(i + 1)) {
        max_val[i] = i + 1;
        sum++;
        min_val[i] = 1;
      } else if (j != i) {
        tarr[val[j + 1] - 'a']++;
        if (check2(i - j)) {
          sum += total[j];
          max_val[i] = max(max_val[i], max(max_val[j], i - j));
          min_val[i] = min(min_val[i], min_val[j] + 1);
        }
      }
    }
    total[i] = sum % mod;
  }
}
int main() {
  cin >> n >> val;
  for (int i = 0; i < 26; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) min_val[i] = 1000000;
  make_dp();
  give_ans();
  cout << total[n - 1] << endl;
  cout << max_val[n - 1] << endl;
  cout << min_val[n - 1] << endl;
  return 0;
}
