#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 50;
const long long maxc = 8;
long long mian() {
  long long s = 0, f = 1;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (f = -1);
  for (s = ch - '0'; isdigit(ch = getchar()); s = s * 10 + ch - '0')
    ;
  return s * f;
}
struct ED {
  long long to, dis;
  ED *nt;
};
ED *head[maxn];
long long n;
long long ToCol[maxn][maxc];
long long Cdis[maxc][maxc];
long long Cnt[maxc][256];
long long mark[maxn];
long long c[maxn], ans, bns;
inline void upd(long long a, long long b = 1) {
  if (a > ans)
    ans = a, bns = b;
  else if (a == ans)
    bns += b;
}
void add(long long x, long long y, long long z) {
  static ED s[maxn], *tail = s;
  tail->to = y;
  tail->dis = z;
  tail->nt = head[x];
  head[x] = tail++;
}
void spfa(long long col) {
  static long long inq[maxn];
  memset(inq, 0, sizeof inq);
  for (long long i = 1; i <= n + 20; ++i) ToCol[i][col] = 0x3f3f3f3f;
  queue<long long> q;
  q.push(n + col * 2 + 2);
  inq[col * 2 + n + 2] = 1;
  ToCol[col * 2 + n + 2][col] = 0;
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    inq[x] = 0;
    for (ED *i = head[x]; i; i = i->nt) {
      if (ToCol[i->to][col] > ToCol[x][col] + i->dis) {
        ToCol[i->to][col] = ToCol[x][col] + i->dis;
        if (!inq[i->to]) inq[i->to] = 1, q.push(i->to);
      }
    }
  }
}
signed main() {
  n = mian();
  for (long long i = 1; i < n; ++i) add(i, i + 1, 1), add(i + 1, i, 1);
  for (long long i = 1; i <= 16; i += 2) add(i + n, i + n + 1, 1);
  for (long long i = 1; i <= n; ++i) {
    char ch;
    while (!isalpha(ch = getchar()))
      ;
    c[i] = ch - 'a';
    add(i, n + c[i] * 2 + 1, 0);
    add(n + c[i] * 2 + 2, i, 0);
  }
  for (long long i = 0; i < 8; ++i) spfa(i);
  memset(Cdis, 0x3f, sizeof Cdis);
  for (long long i = 1; i <= n; ++i)
    for (long long j = 0; j < 8; ++j)
      Cdis[c[i]][j] = min(Cdis[c[i]][j], ToCol[i][j]);
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 0; j < 8; ++j)
      if (Cdis[c[i]][j] < ToCol[i][j]) mark[i] |= 1 << j;
  }
  ans = bns = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = max(1LL, i - 15); j < i; ++j) {
      long long fuck = i - j;
      for (long long k = 0; k < 8; ++k) {
        fuck = min(fuck, ToCol[i][k] + ToCol[j][k] + 1);
      }
      upd(fuck);
    }
    long long t = i - 16;
    if (t >= 1) Cnt[c[t]][mark[t]]++;
    for (long long j = 0; j < 8; ++j) {
      for (long long k = 0; k < 256; ++k) {
        if (Cnt[j][k]) {
          long long fuck = 0x7fffffff;
          for (long long l = 0; l < 8; ++l) {
            fuck = min(fuck, Cdis[j][l] + ToCol[i][l] + ((k >> l) & 1) + 1);
          }
          upd(fuck, Cnt[j][k]);
        }
      }
    }
  }
  cout << ans << ' ' << bns << endl;
  return 0;
}
