#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 10;
int main(void) {
  long long n;
  std::string str;
  std::cin >> n >> str;
  long long cnt[26];
  for (long long i = 0; i < 26; ++i) {
    std::cin >> cnt[i];
  }
  long long res = 0;
  std::vector<long long> dp1(n + 1), dp2(n + 1, INF);
  dp2[n] = 0;
  dp1[n] = 1;
  for (long long i = n - 1; i >= 0; --i) {
    long long r = INF;
    for (long long j = i; j < std::min(r + i, n); ++j) {
      r = std::min(cnt[str[j] - 'a'], r);
      if (r >= j - i + 1) {
        res = std::max(res, j - i + 1);
        dp1[i] = (dp1[i] + dp1[j + 1]) % (long long)(1e9 + 7);
        dp2[i] = std::min(dp2[j + 1] + 1, dp2[i]);
      }
    }
  }
  std::cout << dp1[0] << std::endl << res << std::endl << dp2[0] << std::endl;
  return 0;
}
