#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10, inf = 100000000;
int s[maxn], dis[maxn][10], d[10][10], mask[maxn], cnt[10][260];
int h[maxn * 2], go[maxn * 6], nxt[maxn * 4], f[maxn * 2], dl[maxn * 2],
    id[maxn], b[maxn];
bool bz[maxn * 2], pd[10], czy;
int i, j, k, l, r, v, t, n, m, tot, top, ca, mx, head, tail, now, all, lim;
long long ans;
char get() {
  char ch = getchar();
  while (ch < 'a' || ch > 'h') ch = getchar();
  return ch;
}
void add(int x, int y) {
  go[++tot] = y;
  nxt[tot] = h[x];
  h[x] = tot;
}
void work(int c) {
  if (!pd[c]) return;
  int i;
  head = tail = 0;
  for (i = 1; i <= top; i++) bz[i] = f[i] = 0;
  for (i = 1; i <= n; i++)
    if (s[i] == c) {
      bz[i] = 1;
      dl[++tail] = i;
    }
  while (head < tail) {
    now = dl[++head];
    t = h[now];
    while (t) {
      if (!bz[go[t]]) {
        bz[go[t]] = 1;
        f[go[t]] = f[now] + 1;
        dl[++tail] = go[t];
      }
      t = nxt[t];
    }
  }
  for (i = 1; i <= n; i++) dis[i][c] = f[i] / 2;
}
int main() {
  czy = 1;
  all = 255;
  lim = 16;
  ca = 1;
  while (ca--) {
    for (i = 0; i <= 7; i++) pd[i] = 0;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
      s[i] = get() - 'a';
      pd[s[i]] = 1;
    }
    tot = 0;
    top = n + 8;
    for (i = 1; i <= n - 1; i++) id[i] = ++top;
    for (i = 1; i <= top; i++) h[i] = 0;
    for (i = 1; i <= n; i++) {
      if (i > 1) {
        add(i, id[i - 1]);
        add(id[i - 1], i);
      }
      if (i < n) {
        add(i, id[i]);
        add(id[i], i);
      }
      add(i, n + s[i] + 1);
      add(n + s[i] + 1, i);
    }
    for (i = 0; i <= 7; i++) work(i);
    for (i = 0; i <= 7; i++)
      for (j = 0; j <= 7; j++) d[i][j] = inf;
    for (i = 1; i <= n; i++)
      for (j = 0; j <= 7; j++) {
        d[s[i]][j] = min(d[s[i]][j], dis[i][j]);
        d[j][s[i]] = min(d[j][s[i]], dis[i][j]);
      }
    for (i = 1; i <= n; i++) {
      mask[i] = 0;
      for (j = 0; j <= 7; j++) {
        mask[i] *= 2;
        if (!pd[j]) continue;
        mask[i] += dis[i][j] - d[s[i]][j];
        if (dis[i][j] - d[s[i]][j] < 0 || dis[i][j] - d[s[i]][j] > 1) czy = 0;
      }
    }
    for (i = 0; i <= 7; i++)
      for (j = 0; j <= all; j++) cnt[i][j] = 0;
    mx = 0;
    ans = 0;
    for (i = 1; i <= n; i++) {
      for (j = max(i - lim + 1, 1); j <= i; j++) {
        t = i - j;
        for (k = 0; k <= 7; k++) {
          if (!pd[k]) continue;
          t = min(t, dis[i][k] + 1 + dis[j][k]);
        }
        if (t > mx) {
          mx = t;
          ans = 1;
        } else if (t == mx)
          ans++;
      }
      if (i - lim > 0) {
        j = i - lim;
        for (k = 0; k <= all; k++)
          if ((k & mask[j]) == k) cnt[s[j]][k]++;
      }
      for (k = 0; k <= 7; k++) {
        if (!pd[k] || !cnt[k][0]) continue;
        t = inf;
        r = 0;
        for (l = 0; l <= 7; l++) {
          if (!pd[l]) continue;
          v = dis[i][l] + 1 + d[k][l];
          t = min(t, v);
        }
        for (l = 0; l <= 7; l++)
          if (pd[l] && dis[i][l] + 1 + d[k][l] == t) r += (1 << (7 - l));
        if (cnt[k][r]) {
          if (t + 1 > mx) {
            mx = t + 1;
            ans = cnt[k][r];
          } else if (t + 1 == mx)
            ans += (long long)cnt[k][r];
        } else if (cnt[k][0]) {
          if (t > mx) {
            mx = t;
            ans = cnt[k][0];
          } else if (t == mx)
            ans += (long long)cnt[k][0];
        }
      }
    }
    printf("%d %I64d\n", mx, ans);
  }
}
