#include <bits/stdc++.h>
using namespace std;
const int mx = 15;
int n, a[200005], vis[200005], vis2[10], f[200005][10], g[10][10], h[10][260],
    ans;
long long cnt;
char s[200005];
queue<int> q;
vector<int> v[200005];
void bfs(int c) {
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (x > 1 && !vis[x - 1]) {
      f[x - 1][c] = f[x][c] + 1;
      vis[x - 1] = 1;
      q.push(x - 1);
    }
    if (x < n && !vis[x + 1]) {
      f[x + 1][c] = f[x][c] + 1;
      vis[x + 1] = 1;
      q.push(x + 1);
    }
    if (!vis2[a[x]]) {
      g[a[x]][c] = f[x][c];
      vis2[a[x]] = 1;
      for (auto y : v[a[x]]) {
        if (vis[y]) continue;
        f[y][c] = f[x][c] + 1;
        vis[y] = 1;
        q.push(y);
      }
    }
  }
}
inline void chkmax(int x, int c) {
  if (ans < x)
    ans = x, cnt = c;
  else if (ans == x)
    cnt += c;
}
int main() {
  scanf("%d %s", &n, s + 1);
  memset(f, 0x3f, sizeof(f));
  memset(g, 0x3f, sizeof(g));
  for (int i = 1; i <= n; i++) a[i] = s[i] - 'a', v[a[i]].push_back(i);
  for (int c = 0; c < 8; c++) {
    for (int i = 1; i <= n; i++) vis[i] = 0;
    for (int i = 0; i < 8; i++) vis2[i] = 0;
    g[c][c] = 0;
    vis2[c] = 1;
    for (auto i : v[c]) {
      f[i][c] = 0;
      vis[i] = 1;
      q.push(i);
    }
    bfs(c);
  }
  for (int i = 1; i <= n; i++)
    for (int j = max(1, i - mx); j < i; j++) {
      int dis = i - j;
      for (int c = 0; c < 8; c++) dis = min(dis, f[i][c] + f[j][c] + 1);
      chkmax(dis, 1);
    }
  for (int i = mx + 2; i <= n; i++) {
    int j = i - mx - 1, S = 0;
    for (int c = 0; c < 8; c++) S |= ((f[j][c] - g[a[j]][c]) << c);
    h[a[j]][S]++;
    for (int c = 0; c < 8; c++)
      for (int S = 0; S < (1 << 8); S++) {
        if (!h[c][S]) continue;
        int dis = 0x3f3f3f3f;
        for (int c2 = 0; c2 < 8; c2++)
          dis = min(dis, f[i][c2] + g[c][c2] + 1 + ((S >> c2) & 1));
        chkmax(dis, h[c][S]);
      }
  }
  printf("%d %lld\n", ans, cnt);
  return 0;
}
