#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100010;
const int inf = 1 << 23;
int dis1[Maxn][10], dis2[10][10];
int po[Maxn], sum[10][1 << 8], dis[10][1 << 8][10][1 << 8];
int n;
int _min(int x, int y) { return x < y ? x : y; }
struct node {
  int y, next, d;
} a[Maxn << 2];
int first[Maxn], len;
void ins(int x, int y, int d) {
  len++;
  a[len].y = y;
  a[len].d = d;
  a[len].next = first[x];
  first[x] = len;
}
char s[Maxn];
struct dnode {
  int x, co;
  dnode(int x = 0, int co = 0) : x(x), co(co) {}
};
queue<dnode> q;
void fill(int x, int co) {
  for (int k = first[x]; k; k = a[k].next) {
    int y = a[k].y;
    if (a[k].d == 0 && dis1[y][co] == inf) {
      dis1[y][co] = dis1[x][co];
      q.push(dnode(y, co));
    }
  }
}
void bfs() {
  while (!q.empty()) {
    dnode x = q.front();
    q.pop();
    for (int k = first[x.x]; k; k = a[k].next) {
      int y = a[k].y;
      if (dis1[y][x.co] == inf) {
        dis1[y][x.co] = dis1[x.x][x.co] + a[k].d;
        fill(y, x.co);
        q.push(dnode(y, x.co));
      }
    }
  }
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  scanf("%s", s + 1);
  for (i = 1; i <= n; i++) {
    ins(i, s[i] - 'a' + 1 + n, 1);
    ins(s[i] - 'a' + 1 + n, i, 0);
    if (i < n) ins(i, i + 1, 1), ins(i + 1, i, 1);
  }
  for (i = 1; i <= n + 8; i++)
    for (j = 1; j <= 8; j++) dis1[i][j] = inf;
  for (i = 1; i <= n; i++) {
    dis1[i][s[i] - 'a' + 1] = 0;
    q.push(dnode(i, s[i] - 'a' + 1));
  }
  bfs();
  for (i = 1; i <= 8; i++)
    for (j = 1; j <= 8; j++) dis2[i][j] = inf;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= 8; j++)
      dis2[s[i] - 'a' + 1][j] = dis2[j][s[i] - 'a' + 1] =
          _min(dis2[s[i] - 'a' + 1][j], dis1[i][j]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= 8; j++)
      po[i] |= (dis1[i][j] - dis2[s[i] - 'a' + 1][j]) << (j - 1);
  }
  for (int ii = 1; ii <= 8; ii++) {
    for (i = 0; i < 1 << 8; i++) {
      for (int jj = 1; jj <= 8; jj++) {
        for (j = 0; j < 1 << 8; j++) {
          int dd = inf;
          for (k = 0; k < 8; k++) {
            int x = 0, y = 0;
            if (i & (1 << k)) x = 1;
            if (j & (1 << k)) y = 1;
            dd = _min(dd, dis2[ii][k + 1] + dis2[jj][k + 1] + x + y + 1);
          }
          dis[ii][i][jj][j] = dd;
        }
      }
    }
  }
  long long ans = 0;
  int maxdis = 0;
  for (i = 1; i <= n; i++) {
    for (j = i - 1; j > i - 16; j--) {
      if (j <= 0) break;
      int dd = i - j;
      for (k = 1; k <= 8; k++) dd = _min(dd, dis1[i][k] + dis1[j][k] + 1);
      if (dd > maxdis)
        maxdis = dd, ans = 1;
      else if (dd == maxdis)
        ans++;
    }
    if (i > 16) sum[s[i - 16] - 'a' + 1][po[i - 16]]++;
    for (j = 1; j <= 8; j++) {
      for (k = 0; k < 1 << 8; k++) {
        if (!sum[j][k]) continue;
        if (dis[s[i] - 'a' + 1][po[i]][j][k] > maxdis)
          maxdis = dis[s[i] - 'a' + 1][po[i]][j][k], ans = sum[j][k];
        else if (dis[s[i] - 'a' + 1][po[i]][j][k] == maxdis)
          ans += sum[j][k];
      }
    }
  }
  printf("%d %I64d\n", maxdis, ans);
  return 0;
}
