#include <bits/stdc++.h>
using namespace std;
long long sum;
char str[200010];
int ans, d[9][9], dis[200010][9], f[9][1010], a[200010], n, add[200010];
int main() {
  scanf("%d%s", &n, str + 1);
  for (int i = 1; i <= n; i++) a[i] = str[i] - 'a';
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++)
      if (i != j) d[i][j] = n;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      if (j != a[i]) dis[i][j] = n;
  for (int t = 0; t < 8; t++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < 8; j++) {
        if (i > 1) dis[i][j] = min(dis[i][j], dis[i - 1][j] + 1);
        if (i < n) dis[i][j] = min(dis[i][j], dis[i + 1][j] + 1);
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 0; j < 8; j++) d[a[i]][j] = min(d[a[i]][j], dis[i][j]);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j < 8; j++) dis[i][j] = min(dis[i][j], d[a[i]][j] + 1);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      if (d[a[i]][j] < dis[i][j]) add[i] += (1 << j);
  for (int i = 1; i <= n; i++) {
    for (int j = max(1, i - 15); j < i; j++) {
      int minn = i - j;
      for (int k = 0; k < 8; k++) minn = min(minn, dis[i][k] + dis[j][k] + 1);
      if (ans == minn) sum++;
      if (ans < minn) ans = minn, sum = 1;
    }
    if (i - 16 <= 0) continue;
    f[a[i - 16]][add[i - 16]]++;
    for (int c = 0; c < 8; c++)
      for (int j = 0; j < (1 << 8); j++)
        if (f[c][j]) {
          int len = n;
          for (int k = 0; k < 8; k++)
            len = min(len, dis[i][k] + d[c][k] + 1 + (j >> k & 1));
          if (ans == len) sum += f[c][j];
          if (ans < len) ans = len, sum = f[c][j];
        }
  }
  printf("%d %I64d\n", ans, sum);
}
