#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, inf;
char str[N + 10];
int idx[N + 10], f[N + 3][8], g[8][8], mak[N + 3], cnt[1 << 8][8];
queue<int> que;
void CalF(int col) {
  for (int i = 1; i <= n; i++)
    if (idx[i] == col) {
      que.push(i);
      f[i][col] = 0;
    }
  bool vis[8] = {};
  vis[col] = true;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (!vis[idx[u]]) {
      vis[idx[u]] = true;
      for (int i = 1; i <= n; i++)
        if (idx[i] == idx[u] && f[i][col] == inf) {
          f[i][col] = f[u][col] + 1;
          que.push(i);
        }
    }
    for (int i = -1; i <= 1; i += 2) {
      int v = u + i;
      if (v < 1 || v > n || f[v][col] != inf) continue;
      f[v][col] = f[u][col] + 1;
      que.push(v);
    }
  }
}
int main() {
  scanf("%d%s", &n, str + 1);
  for (int i = 1; i <= n; i++) idx[i] = str[i] - 'a';
  memset(f, 0x3f, sizeof f);
  inf = f[0][0];
  for (int i = 0; i < 8; i++) CalF(i);
  memset(g, 0x3f, sizeof g);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++) g[idx[i]][j] = min(g[idx[i]][j], f[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++) mak[i] |= (f[i][j] == g[idx[i]][j] + 1) << j;
  int ans = -1;
  long long cans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = max(1, i - 15); j < i; j++) {
      int now = i - j;
      for (int k = 0; k < 8; k++) now = min(now, f[i][k] + f[j][k] + 1);
      if (now > ans) ans = now, cans = 0;
      if (now == ans) cans++;
    }
    if (i - 16 >= 1) cnt[mak[i - 16]][idx[i - 16]]++;
    for (int j = 0; j < 8; j++)
      for (int S = (1 << 8) - 1; S >= 0; S--)
        if (cnt[S][j]) {
          int now = inf;
          for (int c = 0; c < 8; c++)
            now = min(now, f[i][c] + 1 + g[j][c] + (S >> c & 1));
          if (now > ans) ans = now, cans = 0;
          if (now == ans) cans += cnt[S][j];
        }
  }
  printf("%d %lld\n", ans, cans);
  return 0;
}
