#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
int dis[N][8], d[8][8], val[N], n;
vector<int> G[8];
char S[N];
queue<int> q;
inline void push(int v, int c, int D) {
  if (dis[v][c] <= D) return;
  dis[v][c] = D, q.push(v);
}
void BFS(int c) {
  dis[n + c][c] = 0;
  q.push(n + c);
  while (!q.empty()) {
    int o = q.front();
    q.pop();
    if (o >= n)
      for (int v : G[o - n]) push(v, c, dis[o][c]);
    else {
      if (o) push(o - 1, c, dis[o][c] + 1);
      if (o < n - 1) push(o + 1, c, dis[o][c] + 1);
      push(val[o] + n, c, dis[o][c] + 1);
    }
  }
}
int mask[N], cnt[8][256];
long long ans[20];
int main() {
  int Case = 1;
  while (Case--) {
    scanf("%d%s", &n, S);
    for (int i = 0; i <= 7; i++) G[i].clear();
    for (int i = 0; i <= n - 1; i++)
      val[i] = S[i] - 'a', G[val[i]].push_back(i), mask[i] = 0;
    memset(dis, 0x1f, sizeof dis), memset(d, 0x1f, sizeof d);
    memset(cnt, 0, sizeof cnt), memset(ans, 0, sizeof ans);
    for (int c = 0; c <= 7; c++) BFS(c);
    for (int i = 0; i <= n - 1; i++)
      for (int j = 0; j <= 7; j++) d[val[i]][j] = min(d[val[i]][j], dis[i][j]);
    for (int i = 0; i <= n - 1; i++)
      for (int j = 0; j <= 7; j++) mask[i] |= (dis[i][j] - d[val[i]][j]) << j;
    for (int i = 0; i <= n - 1; i++) {
      for (int j = 1; j <= min(i, 7); j++) {
        int mind = j;
        for (int c = 0; c <= 7; c++)
          mind = min(mind, dis[i][c] + dis[i - j][c] + 1);
        ans[mind]++;
      }
      for (int j = 0; j <= 7; j++) {
        int mind = 1e9, st = 0;
        for (int c = 0; c <= 7; c++) mind = min(mind, dis[i][c] + 1 + d[j][c]);
        if (mind > 17) continue;
        for (int c = 0; c <= 7; c++)
          if (dis[i][c] + 1 + d[j][c] == mind) st |= 1 << c;
        ans[mind + 1] += cnt[j][st], ans[mind] += cnt[j][0] - cnt[j][st];
      }
      if (i >= 7) {
        int s = mask[i - 7];
        for (int j = s;; j = (j - 1) & s) {
          cnt[val[i - 7]][j]++;
          if (!j) break;
        }
      }
    }
    ans[0] = n;
    for (int i = 17; i >= 0; i--)
      if (ans[i]) {
        cout << i << ' ' << ans[i] << endl;
        break;
      }
  }
  return 0;
}
