#include <bits/stdc++.h>
using namespace std;
int n, f[100010][16], dis[25][25], q[100010], dist[100010], zt[100010], ans,
    num[100010][257];
long long shu;
char s[100010];
bool p[16];
inline int read() {
  int sum = 0, rt = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') rt = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) {
    sum = (sum << 1) + (sum << 3) + (c ^ 48);
    c = getchar();
  }
  return sum * rt;
}
void bfs(int c) {
  int l = 0, r = 0;
  for (int i = 1; i <= n; ++i)
    if (s[i] - 'a' == c) {
      q[r++] = i;
      dist[i] = 0;
    } else
      dist[i] = -1;
  memset(p, 0, sizeof(p));
  p[c] = 1;
  while (l < r) {
    int k = q[l++];
    if (!p[s[k] - 'a']) {
      p[s[k] - 'a'] = 1;
      for (int i = 1; i <= n; ++i)
        if (dist[i] == -1 && s[i] == s[k]) {
          dist[i] = dist[k] + 1;
          q[r++] = i;
        }
    }
    if (k > 1 && dist[k - 1] == -1) q[r++] = k - 1, dist[k - 1] = dist[k] + 1;
    if (k < n && dist[k + 1] == -1) q[r++] = k + 1, dist[k + 1] = dist[k] + 1;
  }
  for (int i = 1; i <= n; ++i)
    if (dist[i] != -1) f[i][c] = dist[i];
}
int main() {
  n = read();
  scanf("%s", s + 1);
  memset(f, 0x3f, sizeof(f));
  memset(dis, 0x3f, sizeof(dis));
  for (int i = 0; i < 8; ++i) bfs(i);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 8; ++j)
      dis[s[i] - 'a'][j] = min(f[i][j], dis[s[i] - 'a'][j]);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 8; ++j)
      if (dis[s[i] - 'a'][j] < f[i][j]) zt[i] |= 1 << j;
  for (int i = 1; i <= n; ++i) {
    for (int j = max(1, i - 15); j < i; ++j) {
      int he = i - j;
      for (int k = 0; k < 8; k++) he = min(he, f[j][k] + 1 + f[i][k]);
      if (he == ans) ++shu;
      if (he > ans) ans = he, shu = 1;
    }
    if (i >= 17) ++num[s[i - 16] - 'a'][zt[i - 16]];
    for (int j = 0; j < 8; ++j)
      for (int z = 0; z < 256; ++z)
        if (num[j][z]) {
          int he = INT_MAX;
          for (int t = 0; t < 8; ++t)
            he = min(he, f[i][t] + dis[j][t] + 1 + ((z & (1 << t)) >> t));
          if (he == ans) shu += num[j][z];
          if (he > ans) ans = he, shu = num[j][z];
        }
  }
  printf("%d %lld\n", ans, shu);
  return 0;
}
