#include <bits/stdc++.h>
using namespace std;
int gi() {
  int res = 0, s = 1;
  char ch;
  for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') s = -1, ch = getchar();
  for (; ch >= '0' && ch <= '9'; ch = getchar()) res = res * 10 + ch - 48;
  return res * s;
}
int n, m, dis[100010][9], d[9][9], last[9], c[100010], que[100010 << 2], h, t,
    mask[100010], tong[9][280];
long long sum[20];
char str[100010];
void init() {
  memset(dis, 0x3f3f3f3f, sizeof(dis));
  memset(d, 0x3f3f3f3f, sizeof(d));
  memset(tong, 0, sizeof(tong));
  memset(mask, 0, sizeof(mask));
  memset(sum, 0, sizeof(sum));
}
int main() {
  n = gi();
  m = 8;
  scanf("%s", str + 1);
  for (int i = 1; i <= n; ++i) c[i] = str[i] - 'a' + 1;
  init();
  for (int i = 1; i <= m; ++i) {
    que[h = t = n + m] = n + i, d[i][i] = 0;
    while (h <= t) {
      int p = que[h];
      h++;
      if (p > n) {
        for (int j = 1; j <= n; ++j)
          if (c[j] == p - n && dis[j][i] > d[p - n][i])
            dis[j][i] = d[p - n][i], que[--h] = j;
      } else {
        if (p > 1 && dis[p - 1][i] > dis[p][i] + 1)
          dis[p - 1][i] = dis[p][i] + 1, que[++t] = p - 1;
        if (p < n && dis[p + 1][i] > dis[p][i] + 1)
          dis[p + 1][i] = dis[p][i] + 1, que[++t] = p + 1;
        if (d[c[p]][i] > dis[p][i] + 1)
          d[c[p]][i] = dis[p][i] + 1, que[++t] = c[p] + n;
      }
    }
  }
  for (int i = 1; i <= m; ++i) {
    d[i][i] = 0;
    for (int j = 1; j <= m; ++j)
      if (i != j) d[i][j]--;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (dis[i][j] > d[c[i]][j]) mask[i] |= (1 << (j - 1));
  for (int i = 1; i <= n; ++i) {
    if (i > 2 * m) {
      for (int sub = mask[i - 2 * m]; sub; sub = (sub - 1) & mask[i - 2 * m])
        tong[c[i - 2 * m]][sub]++;
      tong[c[i - 2 * m]][0]++;
    }
    for (int j = 1; j <= 2 * m - 1 && j < i; ++j) {
      int ds = j;
      for (int trans = 1; trans <= m; ++trans)
        ds = min(ds, dis[i - j][trans] + dis[i][trans] + 1);
      sum[ds]++;
    }
    for (int to = 1; to <= m; ++to) {
      int ds = 0x3f3f3f3f, sub = 0;
      for (int trans = 1; trans <= m; ++trans)
        ds = min(ds, dis[i][trans] + d[trans][to] + 1);
      if (ds > 2 * m - 1) continue;
      for (int trans = 1; trans <= m; ++trans)
        if (dis[i][trans] + d[trans][to] + 1 == ds) sub |= (1 << (trans - 1));
      sum[ds] += tong[to][0] - tong[to][sub];
      sum[ds + 1] += tong[to][sub];
    }
  }
  for (int i = 2 * m - 1; i >= 0; --i)
    if (sum[i] > 0) {
      printf("%d %I64d\n", i, sum[i]);
      break;
    }
  return 0;
}
