#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100050;
const int INF = 0x3f3f3f3f;
int len, n;
char str[MAXN];
int d[10][10];
int dis[MAXN][10], g[MAXN], cnt[256][15], Msk[MAXN];
queue<int> Q;
void bfs(int x) {
  dis[x + n][x] = 0;
  for (int i = 1; i <= n; i++)
    if (str[i] - 'a' + 1 == x) Q.push(i), dis[i][x] = 0;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    if (v <= n) {
      if (v < n) {
        if (dis[v + 1][x] == INF) {
          dis[v + 1][x] = dis[v][x] + 1;
          Q.push(v + 1);
          if (dis[str[v + 1] - 'a' + 1 + n][x] == INF) {
            dis[str[v + 1] - 'a' + 1 + n][x] = dis[v][x] + 1;
            Q.push(str[v + 1] - 'a' + 1 + n);
          }
        }
      }
      if (v > 1) {
        if (dis[v - 1][x] == INF) {
          dis[v - 1][x] = dis[v][x] + 1;
          Q.push(v - 1);
          if (dis[str[v - 1] - 'a' + 1 + n][x] == INF) {
            dis[str[v - 1] - 'a' + 1 + n][x] = dis[v][x] + 1;
            Q.push(str[v - 1] - 'a' + 1 + n);
          }
        }
      }
    } else {
      for (int i = 1; i <= n; i++) {
        if (str[i] - 'a' + 1 + n == v && dis[i][x] == INF) {
          dis[i][x] = dis[v][x] + 1;
          Q.push(i);
        }
      }
    }
  }
  for (int i = n + 1; i <= n + 8; i++) {
    d[i - n][x] = dis[i][x];
    d[x][i - n] = d[i - n][x];
  }
}
int ans;
long long _ans;
int main() {
  scanf("%d", &n);
  scanf("%s", str + 1);
  memset(d, 1, sizeof d);
  for (int i = 1; i <= 8; i++)
    for (int j = 0; j <= n + 8; j++) dis[j][i] = INF;
  for (int i = 1; i <= 8; i++) bfs(i);
  for (int i = 1; i <= n; i++) {
    Msk[i] = 0;
    for (int j = 1; j <= 8; j++) {
      Msk[i] ^= (1 << j - 1) * (dis[i][j] != d[str[i] - 'a' + 1][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = max(i - 15, 1); j < i; j++) {
      int D = i - j;
      for (int c = 1; c <= 8; c++) {
        D = min(D, dis[i][c] + 1 + dis[j][c]);
      }
      if (ans == D)
        _ans++;
      else if (ans < D)
        ans = D, _ans = 1;
    }
    int t = i - 16;
    if (t >= 1) cnt[Msk[t]][str[t] - 'a' + 1]++;
    for (int j = 0; j < 256; j++) {
      for (int c = 1; c <= 8; c++) {
        if (!cnt[j][c]) continue;
        int D = INF;
        for (int k = 1; k <= 8; k++)
          D = min(D, dis[i][k] + 1 + d[c][k] + (j & (1 << k - 1)));
        if (ans == D)
          _ans += cnt[j][c];
        else if (ans < D)
          ans = D, _ans = cnt[j][c];
      }
    }
  }
  printf("%d %I64d\n", ans, _ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
