#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, F = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') F = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * F;
}
int n, pS[200000 + 5];
char s[200000 + 5];
int col[200000 + 5], f[200000 + 5][8 + 2], g[8 + 5][8 + 2];
int vis[200000 + 5], dp[8 + 1][(1 << 8) + 5],
    val[8 + 2][8 + 2][(1 << 8) + 5][(1 << 8) + 5];
vector<int> p[8 + 5];
queue<int> Q;
long long ans, cnt;
void BFS() {
  memset(f, 0x3f, sizeof(f));
  memset(g, 0x3f, sizeof(g));
  for (int c = 0; c < 8; c++) {
    g[c][c] = 0;
    memset(vis, 0, sizeof(vis));
    vis[n + c + 1] = 1;
    for (int i = 0; i < p[c].size(); i++) {
      int v = p[c][i];
      Q.push(v), f[v][c] = 0, vis[v] = 1;
    }
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      if (x != 1 && !vis[x - 1])
        Q.push(x - 1), vis[x - 1] = 1, f[x - 1][c] = f[x][c] + 1;
      if (x != n && !vis[x + 1])
        Q.push(x + 1), vis[x + 1] = 1, f[x + 1][c] = f[x][c] + 1;
      if (!vis[n + col[x] + 1]) {
        vis[n + col[x] + 1] = 1;
        g[col[x]][c] = f[x][c];
        for (int i = 0; i < p[col[x]].size(); i++) {
          int v = p[col[x]][i];
          if (!vis[v]) Q.push(v), f[v][c] = f[x][c] + 1, vis[v] = 1;
        }
      }
    }
  }
}
int main() {
  n = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) col[i] = s[i] - 'a', p[col[i]].push_back(i);
  BFS();
  memset(val, 0x3f, sizeof(val));
  for (int a = 0; a < 8; a++)
    for (int b = 0; b <= a; b++)
      for (int S1 = 0; S1 < (1 << 8); S1++)
        for (int S2 = 0; S2 < (1 << 8); S2++) {
          for (int c = 0; c < 8; c++)
            val[a][b][S1][S2] =
                min(val[a][b][S1][S2],
                    g[a][c] + g[b][c] + ((S1 >> c) & 1) + ((S2 >> c) & 1) + 1);
          val[b][a][S2][S1] = val[a][b][S1][S2];
        }
  for (int i = 1; i <= n; i++) {
    for (int j = max(1, i - 15); j < i; j++) {
      int res = i - j;
      for (int c = 0; c < 8; c++) res = min(res, f[i][c] + f[j][c] + 1);
      if (ans < res) ans = res, cnt = 0;
      if (ans == res) cnt++;
    }
    for (int c = 0; c < 8; c++) pS[i] |= (f[i][c] - g[col[i]][c]) << c;
    for (int c = 0; c < 8; c++)
      for (int S = 0; S < (1 << 8); S++)
        if (dp[c][S]) {
          int res = val[c][col[i]][S][pS[i]];
          if (ans < res) ans = res, cnt = 0;
          if (ans == res) cnt += dp[c][S];
        }
    if (i > 15) dp[col[i - 15]][pS[i - 15]]++;
  }
  printf("%lld %lld", ans, cnt);
}
