#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000;
const int Maxk = 8;
int N;
char s[Maxn + 5];
int f[Maxn + 5][Maxk + 5];
int g[Maxk + 5][Maxk + 5];
vector<int> p[Maxk + 5];
void BFS(int col) {
  static bool vis[Maxn + Maxk + 5];
  memset(vis, false, sizeof vis);
  queue<int> q;
  for (int j = 0; j < (int)p[col].size(); j++)
    q.push(p[col][j]), vis[p[col][j]] = true, f[p[col][j]][col] = 0;
  g[col][col] = 0, vis[N + col] = true;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (u != 1 && !vis[u - 1]) {
      vis[u - 1] = true, q.push(u - 1);
      f[u - 1][col] = f[u][col] + 1;
    }
    if (u != N && !vis[u + 1]) {
      vis[u + 1] = true, q.push(u + 1);
      f[u + 1][col] = f[u][col] + 1;
    }
    if (vis[N + (int)s[u] - 'a' + 1]) continue;
    vis[N + (int)s[u] - 'a' + 1] = true;
    g[s[u] - 'a' + 1][col] = f[u][col];
    for (int i = 0; i < (int)p[s[u] - 'a' + 1].size(); i++) {
      int v = p[s[u] - 'a' + 1][i];
      if (vis[v]) continue;
      f[v][col] = f[u][col] + 1;
      vis[v] = true, q.push(v);
    }
  }
}
int cnt[Maxk + 5][(1 << Maxk) + 5];
int dis[Maxk + 5][Maxk + 5][(1 << Maxk) + 5][(1 << Maxk) + 5];
int st[Maxn + 5];
int main() {
  scanf("%d", &N);
  scanf("%s", s + 1);
  for (int i = 1; i <= N; i++) p[s[i] - 'a' + 1].push_back(i);
  memset(f, 0x3f, sizeof f);
  memset(g, 0x3f, sizeof g);
  for (int i = 1; i <= Maxk; i++) BFS(i);
  memset(dis, 0x3f, sizeof dis);
  for (int col1 = 1; col1 <= 8; col1++)
    for (int col2 = 1; col2 <= col1; col2++)
      for (int s1 = 0; s1 < (1 << 8); s1++)
        for (int s2 = 0; s2 < (1 << 8); s2++) {
          for (int col3 = 1; col3 <= 8; col3++)
            dis[col1][col2][s1][s2] =
                min(dis[col1][col2][s1][s2], g[col1][col3] + g[col2][col3] +
                                                 ((s1 >> (col3 - 1)) & 1) +
                                                 ((s2 >> (col3 - 1)) & 1) + 1);
          dis[col2][col1][s2][s1] = dis[col1][col2][s1][s2];
        }
  int ans = 0;
  long long sum = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = max(1, i - 15); j < i; j++) {
      int tmp = i - j;
      for (int col = 1; col <= 8; col++)
        tmp = min(tmp, f[i][col] + f[j][col] + 1);
      if (ans < tmp) ans = tmp, sum = 0;
      if (ans == tmp) sum++;
    }
    for (int col = 1; col <= 8; col++)
      st[i] |= (f[i][col] - g[s[i] - 'a' + 1][col]) << (col - 1);
    for (int col = 1; col <= 8; col++)
      for (int j = 0; j < (1 << 8); j++)
        if (cnt[col][j]) {
          int tmp = dis[col][s[i] - 'a' + 1][j][st[i]];
          if (ans < tmp) ans = tmp, sum = 0;
          if (ans == tmp) sum += cnt[col][j];
        }
    if (i > 15) cnt[s[i - 15] - 'a' + 1][st[i - 15]]++;
  }
  printf("%d %lld\n", ans, sum);
  return 0;
}
