#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int ALPH = 8;
const int MAXDST = ALPH * 2 - 1;
int n;
char s[MAXN + 1];
int mxdst;
long long cntdst;
bool have[ALPH];
int d[MAXN][ALPH];
int dd[ALPH][ALPH];
int id[MAXN];
int cnt[ALPH][1 << ALPH];
int q[MAXN], qhead, qtail;
void init() {
  mxdst = 0, cntdst = 0;
  memset(have, false, sizeof(have));
  for (int i = (0); i < (n); ++i) have[s[i] - 'a'] = true;
  for (int a = (0); a < (n); ++a)
    for (int c = (0); c < (ALPH); ++c) d[a][c] = INT_MAX;
  for (int sc = (0); sc < (ALPH); ++sc)
    for (int tc = (0); tc < (ALPH); ++tc) dd[sc][tc] = INT_MAX;
  for (int tc = (0); tc < (8); ++tc)
    if (have[tc]) {
      qhead = qtail = 0;
      for (int a = (0); a < (n); ++a)
        if (s[a] == 'a' + tc) {
          d[a][tc] = 0;
          q[qhead++] = a;
        }
      while (qtail < qhead) {
        int a = q[qtail++], c = s[a] - 'a';
        if (a - 1 >= 0 && d[a - 1][tc] == INT_MAX) {
          d[a - 1][tc] = d[a][tc] + 1;
          q[qhead++] = a - 1;
        }
        if (a + 1 < n && d[a + 1][tc] == INT_MAX) {
          d[a + 1][tc] = d[a][tc] + 1;
          q[qhead++] = a + 1;
        }
        if (dd[c][tc] == INT_MAX) {
          dd[c][tc] = d[a][tc];
          for (int b = (0); b < (n); ++b)
            if (s[b] - 'a' == c && d[b][tc] == INT_MAX) {
              d[b][tc] = d[a][tc] + 1;
              q[qhead++] = b;
            }
        }
      }
    }
  for (int a = (0); a < (n); ++a) {
    int msk = 0;
    for (int c = (0); c < (ALPH); ++c)
      if (have[c]) {
        int diff = d[a][c] - dd[s[a] - 'a'][c];
        assert(diff == 0 || diff == 1);
        if (diff == 1) msk |= 1 << c;
      }
    id[a] = msk;
  }
  memset(cnt, 0, sizeof(cnt));
  for (int a = (0); a < (n); ++a) ++cnt[s[a] - 'a'][id[a]];
}
int solve1(int a, int b) {
  int ret = abs(a - b);
  for (int c = (0); c < (8); ++c)
    if (have[c]) {
      int cur = d[a][c] + 1 + d[b][c];
      if (cur < ret) ret = cur;
    }
  return ret;
}
int solve2(int a, int sb, int msk) {
  int ret = INT_MAX;
  for (int c = (0); c < (8); ++c)
    if (have[c]) {
      int cur = d[a][c] + dd[sb][c] + 1 + ((msk >> c) & 1);
      if (cur < ret) ret = cur;
    }
  return ret;
}
void update(int cur, int cnt) {
  if (cur > mxdst) mxdst = cur, cntdst = 0;
  if (cur == mxdst) cntdst += cnt;
}
void run() {
  scanf("%d%s", &n, s);
  n = strlen(s);
  init();
  for (int i = (0); i < (n); ++i) {
    for (int j = (i - MAXDST); j <= (i + MAXDST); ++j)
      if (j >= 0 && j != i && j < n) update(solve1(i, j), 1);
    for (int j = (i - MAXDST); j <= (i + MAXDST); ++j)
      if (j >= 0 && j < n) --cnt[s[j] - 'a'][id[j]];
    for (int sb = (0); sb < (ALPH); ++sb)
      if (have[sb])
        for (int msk = (0); msk < (1 << ALPH); ++msk)
          if (cnt[sb][msk]) update(solve2(i, sb, msk), cnt[sb][msk]);
    for (int j = (i - MAXDST); j <= (i + MAXDST); ++j)
      if (j >= 0 && j < n) ++cnt[s[j] - 'a'][id[j]];
  }
  assert(cntdst % 2 == 0);
  printf("%d %lld\n", mxdst, cntdst / 2);
}
int main() {
  run();
  return 0;
}
