#include <bits/stdc++.h>
using namespace std;
const int INF = 0X3F3F3F3F;
const int N = 200005;
int n, K = 8, q[N], he, ta, dis[N], deg[N], id[N];
char s[N];
long long ans[N];
unsigned long long b[N];
vector<int> e0[N], e1[N], e[N];
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = (1); i <= (n); ++i) {
    int x = s[i] - 'a' + 1;
    e0[i].push_back(n + x), e1[n + x].push_back(i);
  }
  for (int i = (1); i <= (n - 1); ++i) {
    int k1 = i, k2 = i + 1;
    scanf("%d%d", &k1, &k2);
    e1[k1].push_back(k2), e1[k2].push_back(k1);
  }
  memset(id, -1, sizeof(id));
  for (int i = (1); i <= (K); ++i) {
    he = 0, ta = 0;
    q[++ta] = i + n;
    fill(dis + 1, dis + 1 + n + K, K * 2 + 1);
    dis[i + n] = 1;
    while (he != ta) {
      int k1 = q[++he];
      for (int x : e0[k1])
        if (dis[k1] < dis[x]) dis[x] = dis[k1], q[he--] = x;
      for (int x : e1[k1])
        if (dis[k1] + 1 < dis[x]) dis[x] = dis[k1] + 1, q[++ta] = x;
    }
    for (int k1 = (1); k1 <= (n + K); ++k1) e[k1].clear(), deg[k1] = 0;
    for (int k1 = (1); k1 <= (n + K); ++k1) {
      for (int x : e0[k1])
        if (dis[k1] == dis[x]) e[k1].push_back(x), ++deg[x];
      for (int x : e1[k1])
        if (dis[k1] + 1 == dis[x]) e[k1].push_back(x), ++deg[x];
    }
    he = 0, ta = 0;
    for (int x : e[i + n]) {
      assert(!--deg[x]);
      q[++ta] = x;
      id[x] = ta - 1;
    }
    vector<pair<int, int> > t;
    while (he != ta) {
      int k1 = q[++he];
      for (int x : e[k1]) {
        t.emplace_back(x, k1);
        if (!--deg[x]) {
          q[++ta] = x;
        }
      }
    }
    for (int l = 0; l < ((int)(e1[i + n]).size()); l += 64) {
      int r = min(((int)(e1[i + n]).size()) - 1, l + 63), sz = r - l + 1;
      for (int k1 = (1); k1 <= (n + K); ++k1) b[k1] = 0;
      for (int j = (l); j <= (r); ++j) b[e1[i + n][j]] |= 1ULL << (j - l);
      for (auto x : t) {
        b[x.first] |= b[x.second];
      }
      for (int k1 = (1); k1 <= (n); ++k1) {
        int t = __builtin_popcountll(b[k1]);
        ans[dis[k1]] += sz - t;
        ans[dis[k1] - 1] += t;
      }
    }
    for (int x : e[i + n]) id[x] = -1;
  }
  ans[1] = 0;
  int res = K * 2 + 1;
  while (!ans[res]) --res;
  printf("%d %lld\n", res - 1, ans[res] / 2);
  return 0;
}
