#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int d[N], q[N], fi[10], ne[N], f[N][10], dist[10][10], mark[N], num[10][1 << 8],
    nums[10], n;
char s[N];
void bfs(int c) {
  int h = 1, t = 0, u[10];
  for (int i = 1; i <= n; i++)
    if (s[i] - 'a' == c)
      d[q[++t] = i] = 0;
    else
      d[i] = -1;
  for (int i = 0; i < 8; i++) u[i] = 1;
  u[c] = 0;
  for (; h <= t; h++) {
    if (u[s[q[h]] - 'a']) {
      u[s[q[h]] - 'a'] = 0;
      for (int i = fi[s[q[h]] - 'a']; i; i = ne[i])
        if (d[i] == -1) d[q[++t] = i] = d[q[h]] + 1;
    }
    if (q[h] > 1 && d[q[h] - 1] == -1) d[q[++t] = q[h] - 1] = d[q[h]] + 1;
    if (q[h] < n && d[q[h] + 1] == -1) d[q[++t] = q[h] + 1] = d[q[h]] + 1;
  }
  for (int i = 1; i <= n; i++) f[i][c] = d[i];
}
int main() {
  scanf("%d\n%s", &n, s + 1);
  for (int i = 1; i <= n; i++) {
    ne[i] = fi[s[i] - 'a'];
    fi[s[i] - 'a'] = i;
  }
  for (int i = 0; i < 8; i++) bfs(i);
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) dist[i][j] = -1;
  for (int i = 1, j; i <= n; i++)
    for (j = 0; j < 8; j++)
      if (f[i][j] != -1 &&
          (dist[s[i] - 'a'][j] == -1 || f[i][j] < dist[s[i] - 'a'][j]))
        dist[s[i] - 'a'][j] = f[i][j];
  for (int i = 1, j; i <= n; i++) {
    mark[i] = 0;
    for (j = 7; j >= 0; j--)
      mark[i] = mark[i] << 1 ^ (f[i][j] - dist[s[i] - 'a'][j]);
  }
  int ans = 0, now = 1;
  long long ansp = 0;
  for (int i = 1, j, k; i <= n; i++) {
    int l = i;
    for (; l >= 1; l--) {
      int mindst = -1;
      for (j = 0; j < 8; j++)
        if (f[l][j] != -1 && f[i][j] != -1 &&
            (mindst == -1 || f[l][j] + f[i][j] + 1 < mindst))
          mindst = f[l][j] + f[i][j] + 1;
      if (mindst <= i - l) break;
    }
    for (; now <= l; now++) {
      nums[s[now] - 'a']++;
      for (j = mark[now]; j; j = (j - 1) & mark[now]) num[s[now] - 'a'][j]++;
    }
    for (j = 0; j < 8; j++) {
      int mindst = -1, minnum = 0;
      for (k = 0; k < 8; k++)
        if (f[i][k] != -1 && dist[k][j] != -1 &&
            (mindst == -1 || f[i][k] + dist[k][j] + 1 < mindst))
          mindst = f[i][k] + dist[k][j] + 1;
      if (mindst == -1) continue;
      int mrk = 0;
      for (k = 0; k < 8; k++)
        if (f[i][k] != -1 && dist[k][j] != -1 &&
            f[i][k] + dist[k][j] + 1 == mindst)
          mrk ^= 1 << k;
      if (num[j][mrk])
        mindst++, minnum = num[j][mrk];
      else
        minnum = nums[j];
      if (!minnum) continue;
      if (mindst > ans)
        ans = mindst, ansp = minnum;
      else if (mindst == ans)
        ansp = ansp + minnum;
    }
    if (i - now > ans)
      ans = i - now, ansp = 1;
    else if (i - now == ans)
      ansp++;
  }
  printf("%d %lld\n", ans, ansp);
}
