#include <bits/stdc++.h>
const int maxn = 100020, maxm = 8;
int n;
char ss[maxn];
int a[maxn];
int ar[maxm][maxn], nm[maxm];
int f[maxm][maxn];
int q[maxn << 1], hd, tl;
int ms[maxn];
int s[maxm][1 << maxm];
long long sk, sn;
int In() {
  register char c;
  for (; c = getchar(), c != '-' && (c < '0' || c > '9');)
    ;
  register bool f = c == '-';
  register int s = f ? 0 : c - '0';
  for (; c = getchar(), c >= '0' && c <= '9';) s = s * 10 + c - '0';
  return f ? -s : s;
}
void bfs(int s) {
  f[s][n + s] = 0;
  for (q[hd = tl = maxn] = n + s; hd <= tl; ++hd) {
    register int x = q[hd];
    if (x < n) {
      if (f[s][a[x] + n] > f[s][x] + 1)
        f[s][a[x] + n] = f[s][x] + 1, q[++tl] = a[x] + n;
      if (x > 0 && f[s][x - 1] > f[s][x] + 1)
        f[s][x - 1] = f[s][x] + 1, q[++tl] = x - 1;
      if (x < n - 1 && f[s][x + 1] > f[s][x] + 1)
        f[s][x + 1] = f[s][x] + 1, q[++tl] = x + 1;
    } else
      for (register int i = 0; i < nm[x - n]; ++i)
        if (f[s][ar[x - n][i]] > f[s][x])
          f[s][ar[x - n][i]] = f[s][x], q[hd--] = ar[x - n][i];
  }
}
int main() {
  n = In();
  scanf("%s", ss);
  for (register int i = 0; i < n; ++i)
    a[i] = ss[i] - 'a', ar[a[i]][nm[a[i]]++] = i;
  memset(f, 63, sizeof f);
  for (register int i = 0; i < 8; ++i) {
    bfs(i);
    for (register int j = 0; j < n; ++j)
      ms[j] |= (f[i][a[j] + n] - f[i][j]) << i;
  }
  for (register int i = 0; i < n; ++i) {
    for (register int j = i > 15 ? i - 15 : 0; j < i; ++j) {
      register int l = i - j;
      for (register int k = 0; k < 8; ++k)
        l > f[k][i] + f[k][j] + 1 ? l = f[k][i] + f[k][j] + 1 : 0;
      if (sk < l)
        sk = l, sn = 1;
      else if (sk == l)
        ++sn;
    }
    if (i >= 16) ++s[a[i - 16]][ms[i - 16]];
    for (register int j = 0; j < 8; ++j)
      for (register int k = 0; k < 256; ++k)
        if (s[j][k]) {
          register int l = 15;
          for (register int z = 0; z < 8; ++z) {
            register int x = f[z][i] + f[z][j + n] - (k >> z & 1) + 1;
            l > x ? l = x : 0;
          }
          if (sk < l)
            sk = l, sn = s[j][k];
          else if (sk == l)
            sn += s[j][k];
        }
  }
  printf("%lld %lld\n", sk, sn);
  return 0;
}
