#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
inline int read() {
  static char ch;
  register int tmp = 0, fl = 0;
  while (ch = getchar(), ch < '0' || ch > '9') fl |= (ch == '-');
  tmp = ch ^ 48;
  while (ch = getchar(), ch >= '0' && ch <= '9') tmp = tmp * 10 + (ch ^ 48);
  return fl ? -tmp : tmp;
}
inline int ksm(int a, int k) {
  int ans = 1;
  for (; k; k >>= 1, a = 1ll * a * a % mod)
    if (k & 1) ans = 1ll * ans * a % mod;
  return ans;
}
int n, f[100010][10], dis[10][10], S[100010], mx = 0, cnt[10][300];
long long tmp = 0;
bool vis[10];
char a[100010];
queue<int> q;
int main() {
  scanf("%d", &n);
  scanf("%s", a + 1);
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) dis[i][j] = 1e4;
  for (int now = 0; now < 8; now++) {
    for (int i = 1; i <= n; i++) f[i][now] = 1e4;
    for (int j = 0; j < 8; j++) vis[j] = false;
    for (int i = 1; i <= n; i++)
      if (a[i] == now + 'a') q.push(i), f[i][now] = 0, vis[now] = true;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      if (!vis[a[u] - 'a']) {
        for (int i = 1; i <= n; i++)
          if (a[i] == a[u] && f[i][now] > f[u][now] + 1)
            f[i][now] = f[u][now] + 1, q.push(i);
        vis[a[u] - 'a'] = true;
      }
      if (u > 1 && f[u - 1][now] > f[u][now] + 1)
        f[u - 1][now] = f[u][now] + 1, q.push(u - 1);
      if (u < n && f[u + 1][now] > f[u][now] + 1)
        f[u + 1][now] = f[u][now] + 1, q.push(u + 1);
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      dis[a[i] - 'a'][j] = min(dis[a[i] - 'a'][j], f[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      if (dis[a[i] - 'a'][j] != f[i][j]) S[i] |= (1 << j);
  for (int i = 1; i <= n; i++) {
    for (int j = max(1, i - 15); j < i; j++) {
      int d = i - j;
      for (int k = 0; k < 8; k++) d = min(d, f[i][k] + f[j][k] + 1);
      if (d > mx)
        mx = d, tmp = 1;
      else if (d == mx)
        tmp++;
    }
    if (i > 16) cnt[a[i - 16] - 'a'][S[i - 16]]++;
    for (int j = 0; j < 8; j++) {
      for (int T = 0; T < 256; T++) {
        if (!cnt[j][T]) continue;
        int d = 2e9;
        for (int k = 0; k < 8; k++)
          d = min(d, f[i][k] + dis[j][k] + ((T >> k) & 1) + 1);
        if (d > mx)
          mx = d, tmp = cnt[j][T];
        else if (d == mx)
          tmp += cnt[j][T];
      }
    }
  }
  printf("%d %lld\n", mx, tmp);
}
