#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
class TaskC {
 public:
  void solve(istream& in, ostream& out) {
    int n;
    string s;
    vector<int> a(26);
    in >> n >> s;
    for (int i = 0; i < 26; ++i) {
      in >> a[i];
    }
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    int longest = 1;
    for (int i = 0; i < n; ++i) {
      int j = i + 1;
      int curlen = 1, maxlen = a[s[i] - 'a'];
      dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
      while (j < n) {
        maxlen = min(maxlen, a[s[j] - 'a']);
        ++curlen;
        if (curlen <= maxlen) {
          ++j;
          dp[j] = (dp[j] + dp[i]) % MOD;
          longest = max(longest, curlen);
        } else {
          break;
        }
      }
    }
    out << dp[n] << "\n";
    out << longest << "\n";
    int minstrings = 0;
    for (int i = 0; i < n;) {
      int maxlen = a[s[i] - 'a'], curlen = 1;
      while (++i < n && ++curlen <= (maxlen = min(maxlen, a[s[i] - 'a']))) {
      }
      ++minstrings;
    }
    out << minstrings << "\n";
  }
};
int main() {
  std::ios::sync_with_stdio(false);
  TaskC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
