#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int inf = 1 << 29;
char s[N];
int dis[8][N], D[8][8];
int q[N], sum[8][1 << 8], st[N], n;
int func[8][8][1 << 8][1 << 8];
vector<int> v[8];
long long ans[17];
void SSSP(int c) {
  static int vis[10];
  for (int i = (int)(0); i <= (int)(7); i++) vis[i] = (i == c);
  for (int i = (int)(1); i <= (int)(n); i++) dis[c][i] = inf;
  int h = 0, t = 0;
  for (auto i : v[c]) q[++t] = i, dis[c][i] = 0;
  while (h != t) {
    int x = q[++h];
    if (x != 1 && dis[c][x - 1] == inf)
      dis[c][x - 1] = dis[c][x] + 1, q[++t] = x - 1;
    if (x != n && dis[c][x + 1] == inf)
      dis[c][x + 1] = dis[c][x] + 1, q[++t] = x + 1;
    if (!vis[s[x] - 'a']) {
      vis[s[x] - 'a'] = 1;
      for (auto i : v[s[x] - 'a'])
        if (dis[c][i] == inf) dis[c][i] = dis[c][x] + 1, q[++t] = i;
    }
  }
}
void Mn(int &x, int y) { x > y ? x = y : 233; }
int main() {
  scanf("%d%s", &n, s + 1);
  for (int i = (int)(0); i <= (int)(7); i++)
    for (int j = (int)(1); j <= (int)(n); j++)
      if (s[j] == 'a' + i) v[i].push_back(j);
  for (int i = (int)(0); i <= (int)(7); i++) SSSP(i);
  for (int i = (int)(0); i <= (int)(7); i++)
    for (int j = (int)(0); j <= (int)(7); j++) D[i][j] = inf;
  for (int i = (int)(0); i <= (int)(7); i++)
    for (int j = (int)(1); j <= (int)(n); j++) Mn(D[i][s[j] - 'a'], dis[i][j]);
  for (int i = (int)(0); i <= (int)(7); i++)
    for (int j = (int)(1); j <= (int)(n); j++)
      st[j] += (dis[i][j] - D[i][s[j] - 'a']) << i;
  for (int i = (int)(0); i <= (int)(7); i++)
    for (int j = (int)(0); j <= (int)(7); j++)
      for (int s1 = (int)(0); s1 <= (int)(255); s1++)
        for (int s2 = (int)(0); s2 <= (int)(255); s2++) {
          int val = 16;
          for (int k = (int)(0); k <= (int)(7); k++)
            Mn(val, D[i][k] + D[k][j] + 1 + ((s1 >> k) & 1) + ((s2 >> k) & 1));
          func[i][j][s1][s2] = val;
        }
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(max(i - 15, 1)); j <= (int)(i - 1); j++) {
      int val = i - j;
      for (int k = (int)(0); k <= (int)(7); k++)
        Mn(val, dis[k][i] + dis[k][j] + 1);
      ++ans[val];
    }
  for (int i = (int)(1); i <= (int)(n); i++) {
    if (i - 16 >= 1) ++sum[s[i - 16] - 'a'][st[i - 16]];
    for (int j = (int)(0); j <= (int)(7); j++)
      for (int k = (int)(0); k <= (int)(255); k++)
        ans[func[s[i] - 'a'][j][st[i]][k]] += sum[j][k];
  }
  int p = 15;
  for (; !ans[p]; --p)
    ;
  printf("%d %lld\n", p, ans[p]);
}
