#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxc = 8;
const int threa = 2 * maxc - 1;
const int inf = 0x3f3f3f3f;
char str[maxn];
int dis[maxn], cd[maxc][maxc], mask[maxn], col[maxn];
int cou[maxc][1 << maxc];
vector<int> g[maxc];
int get_dis(int j, int c) { return cd[col[j]][c] + ((mask[j] >> c) & 1); }
void update(int &dia, long long &ans, int cd, long long ca) {
  if (cd > dia) {
    dia = cd;
    ans = 0;
  }
  if (dia == cd) ans += ca;
}
int main() {
  int n;
  scanf("%d%s", &n, str);
  for (int i = 0; str[i]; i++) {
    col[i] = str[i] - 'a';
    g[col[i]].push_back(i);
  }
  memset(cd, inf, sizeof(cd));
  memset(mask, 0, sizeof(mask));
  for (int c = 0; c < maxc; c++) {
    cd[c][c] = 0;
    memset(dis, -1, sizeof(dis));
    queue<int> que;
    for (int j = 0; j < g[c].size(); j++) {
      que.push(g[c][j]);
      dis[g[c][j]] = 0;
    }
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      if (cd[col[u]][c] == inf) {
        int cu = col[u];
        cd[cu][c] = dis[u];
        for (int i = 0; i < g[cu].size(); i++)
          if (dis[g[cu][i]] == -1) {
            dis[g[cu][i]] = dis[u] + 1;
            que.push(g[cu][i]);
          }
      }
      for (int i = -1; i <= 1; i += 2) {
        int v = u + i;
        if (v >= 0 && v < n && dis[v] == -1) {
          dis[v] = dis[u] + 1;
          que.push(v);
        }
      }
    }
    if (g[c].size())
      for (int i = 0; i < n; i++) mask[i] |= (dis[i] - cd[col[i]][c]) << c;
  }
  int dia = 0;
  long long ans = 0;
  memset(cou, 0, sizeof(cou));
  for (int i = 0; i < n; i++) {
    for (int j = max(i - threa, 0); j < i; j++) {
      int sp = i - j;
      for (int c = 0; c < maxc; c++)
        sp = min(sp, get_dis(j, c) + 1 + get_dis(i, c));
      update(dia, ans, sp, 1);
    }
    for (int j = 0; j < maxc; j++) {
      for (int msk = 0; msk < (1 << maxc); msk++) {
        if (cou[j][msk] == 0) continue;
        int sp = inf;
        for (int c = 0; c < maxc; c++)
          sp = min(sp, (cd[j][c] + ((msk >> c) & 1)) + 1 + get_dis(i, c));
        update(dia, ans, sp, cou[j][msk]);
      }
    }
    if (i >= threa) ++cou[col[i - threa]][mask[i - threa]];
  }
  printf("%d %lld\n", dia, ans);
  return 0;
}
