#include <bits/stdc++.h>
using namespace std;
const long long N = 100010;
inline long long read() {
  long long p = 0;
  long long f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    p = p * 10 + ch - '0';
    ch = getchar();
  }
  return p * f;
}
char s[N];
long long n;
long long f[N][9];
queue<long long> q;
bool vis[9];
void bfs(long long c) {
  memset(vis, 0, sizeof(vis));
  for (long long i = 1; i <= n; i++)
    if (s[i] == c + 'a') q.push(i), f[i][c] = 0;
  vis[c] = 1;
  while (!q.empty()) {
    long long x = q.front();
    if (!vis[s[x] - 'a']) {
      for (long long i = 1; i <= n; i++)
        if (s[x] == s[i] && f[i][c] > n)
          f[i][c] = min(f[i][c], f[x][c] + 1), q.push(i);
      vis[s[x] - 'a'] = 1;
    }
    if (x - 1 >= 1 && f[x - 1][c] > f[x][c]) {
      f[x - 1][c] = min(f[x - 1][c], f[x][c] + 1);
      q.push(x - 1);
    }
    if (x + 1 <= n && f[x + 1][c] > f[x][c]) {
      f[x + 1][c] = min(f[x + 1][c], f[x][c] + 1);
      q.push(x + 1);
    }
    q.pop();
  }
}
long long dis[9][9], mask[N], cnt[9][260];
long long trans[9][260];
int main() {
  n = read();
  scanf("%s", s + 1);
  memset(f, 63, sizeof(f));
  for (long long i = 0; i < 8; i++) bfs(i);
  memset(dis, 63, sizeof(dis));
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < 8; j++)
      dis[s[i] - 'a'][j] = min(dis[s[i] - 'a'][j], f[i][j]);
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < 8; j++)
      if (dis[s[i] - 'a'][j] != f[i][j]) mask[i] |= (1ll << (j));
  long long ans = 0;
  long long maxx = 0;
  memset(cnt, 0, sizeof(cnt));
  for (long long i = 1; i <= n; i++) {
    long long t = i - 15;
    for (long long j = max(t, 1ll); j < i; j++) {
      long long ss = abs(i - j);
      for (long long k = 0; k < 8; k++) ss = min(ss, f[i][k] + f[j][k] + 1ll);
      if (ss > maxx) {
        maxx = ss;
        ans = 1;
      } else if (ss == maxx)
        ans++;
    }
    if (t > 1) cnt[s[t - 1] - 'a'][mask[t - 1]]++;
    for (long long j = 0; j < 8; j++)
      for (long long k = 0; k < 256; k++)
        if (cnt[j][k]) {
          long long ss = LLONG_MAX;
          for (long long l = 0; l < 8; l++)
            ss = min(ss, f[i][l] + dis[j][l] + ((k & (1ll << (l))) >> l) + 1ll);
          if (ss > maxx) {
            maxx = ss;
            ans = cnt[j][k];
          } else if (ss == maxx)
            ans += cnt[j][k];
        }
  }
  return printf("%lld %lld\n", maxx, ans), 0;
}
