#include <bits/stdc++.h>
using namespace std;
int n, f[100100][16], dis[20][20], que[100100], d[100100], sign[100100],
    c[100100][1 << 8];
char s[100100];
inline void bfs(int c) {
  int l = 0, r = 0;
  for (int i = 1; i <= n; i++)
    if (s[i] - 'a' == c) {
      que[r++] = i, d[i] = 0;
    } else
      d[i] = -1;
  bool flag[16] = {0};
  flag[c] = true;
  while (l < r) {
    int now = que[l++];
    if (!flag[s[now] - 'a']) {
      flag[s[now] - 'a'] = true;
      for (int i = 1; i <= n; i++)
        if (s[i] == s[now] && d[i] == -1) {
          d[i] = d[now] + 1;
          que[r++] = i;
        }
    }
    if (now > 1 && d[now - 1] == -1)
      que[r++] = now - 1, d[now - 1] = d[now] + 1;
    if (now < n && d[now + 1] == -1)
      que[r++] = now + 1, d[now + 1] = d[now] + 1;
  }
  for (int i = 1; i <= n; i++)
    if (d[i] != -1) f[i][c] = d[i];
}
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  memset(f, 0x3f, sizeof f);
  for (int i = 0; i < 8; i++) bfs(i);
  memset(dis, 0x3f, sizeof dis);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      dis[s[i] - 'a'][j] = min(dis[s[i] - 'a'][j], f[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      if (f[i][j] > dis[s[i] - 'a'][j]) sign[i] |= 1 << j;
  int ans = 0;
  long long cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = max(i - 15, 1); j < i; j++) {
      int now = i - j;
      for (int k = 0; k < 8; k++) now = min(now, f[j][k] + 1 + f[i][k]);
      if (now == ans) cnt++;
      if (now > ans) ans = now, cnt = 1;
    }
    int t = i - 16;
    if (t >= 1) c[s[t] - 'a'][sign[t]]++;
    for (int j = 0; j < 8; j++)
      for (int k = 0; k < 256; k++)
        if (c[j][k]) {
          int now = 0x7fffffff;
          for (int l = 0; l < 8; l++) {
            now = min(now, dis[j][l] + 1 + f[i][l] + ((k & (1 << l)) >> l));
          }
          if (now == ans) cnt += c[j][k];
          if (now > ans) ans = now, cnt = c[j][k];
        }
  }
  printf("%d %lld\n", ans, cnt);
}
