#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500;
int n, mp[8][8], dis[N][8], d[8][8], msk[N], ans1, c[8][256];
char s[N];
long long ans2;
inline void Min(int &x, int y) { x = min(x, y); }
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 7; j++) dis[i][j] = (s[i] - 'a' == j ? 0 : 100);
  for (int i = 0; i <= 7; i++)
    for (int j = 0; j <= 7; j++) d[i][j] = (i == j ? 0 : 100);
  for (int pp = 0; pp <= 7; pp++) {
    for (int i = 1; i <= n; i++) {
      if (i > 1)
        for (int j = 0; j <= 7; j++) Min(dis[i][j], dis[i - 1][j] + 1);
      if (i < n)
        for (int j = 0; j <= 7; j++) Min(dis[i][j], dis[i + 1][j] + 1);
    }
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= 7; j++) Min(d[s[i] - 'a'][j], dis[i][j]);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= 7; j++) Min(dis[i][j], d[s[i] - 'a'][j] + 1);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 7; j++) msk[i] |= (dis[i][j] > d[s[i] - 'a'][j]) << j;
  for (int i = 1; i <= n; i++) {
    for (int j = max(i - 15, 1); j <= i - 1; j++) {
      int tmp = i - j;
      for (int k = 0; k <= 7; k++) tmp = min(tmp, dis[i][k] + 1 + dis[j][k]);
      if (tmp > ans1)
        ans1 = tmp, ans2 = 1;
      else if (ans1 == tmp)
        ++ans2;
    }
    if (i - 16 >= 1) ++c[s[i - 16] - 'a'][msk[i - 16]];
    for (int j = 0; j <= 7; j++)
      for (int k = 0; k <= 255; k++)
        if (c[j][k]) {
          int tmp = 100;
          for (int p = 0; p <= 7; p++)
            tmp = min(tmp, d[j][p] + 1 + dis[i][p] + ((k >> p) & 1));
          if (tmp > ans1)
            ans1 = tmp, ans2 = c[j][k];
          else if (ans1 == tmp)
            ans2 += c[j][k];
        }
  }
  printf("%d %I64d\n", ans1, ans2);
  return 0;
}
