#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005, INF = 0x3f3f3f3f, LIM = 15;
int N;
char S[MAX_N];
vector<int> node[8];
queue<int> q;
int dis1[8][8], dis2[8][MAX_N];
void bfs(int s, int *d1, int *d2) {
  static bool vis[8];
  memset(vis, 0, sizeof vis);
  d1[s] = 0, vis[s] = 1;
  for (int i = 0; i < node[s].size(); ++i) {
    d2[node[s][i]] = 0;
    q.push(node[s][i]);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (!vis[S[u]]) {
      d1[S[u]] = d2[u];
      for (int i = 0; i < node[S[u]].size(); ++i)
        if (d2[node[S[u]][i]] > d2[u] + 1) {
          d2[node[S[u]][i]] = d2[u] + 1;
          q.push(node[S[u]][i]);
        }
      vis[S[u]] = 1;
    }
    if (u > 1 && d2[u - 1] > d2[u] + 1) {
      d2[u - 1] = d2[u] + 1;
      q.push(u - 1);
    }
    if (u < N && d2[u + 1] > d2[u] + 1) {
      d2[u + 1] = d2[u] + 1;
      q.push(u + 1);
    }
  }
}
int cnt[8][1 << 8], id[MAX_N];
long long num[20];
void work() {
  memset(dis1, 0x3f, sizeof dis1);
  memset(dis2, 0x3f, sizeof dis2);
  memset(cnt, 0, sizeof cnt);
  memset(num, 0, sizeof num);
  scanf("%d", &N);
  scanf("%s", S + 1);
  for (int i = 0; i < 8; ++i) node[i].clear();
  for (int i = 1; i <= N; ++i) {
    S[i] = S[i] - 'a';
    node[S[i]].push_back(i);
  }
  for (int i = 0; i < 8; ++i) bfs(i, dis1[i], dis2[i]);
  for (int i = 1; i <= N; ++i) {
    int mask = 0;
    for (int j = 0; j < 8; ++j)
      if (dis2[j][i] == dis1[j][S[i]] + 1) mask |= 1 << j;
    cnt[S[i]][mask]++, id[i] = mask;
  }
  for (int c1 = 0; c1 < 8; ++c1)
    for (int mask1 = 0; mask1 < 256; ++mask1)
      if (cnt[c1][mask1])
        for (int c2 = c1; c2 < 8; ++c2)
          for (int mask2 = (c1 == c2 ? mask1 : 0); mask2 < 256; ++mask2)
            if (cnt[c2][mask2]) {
              int now = 20;
              for (int k = 0; k < 8; ++k)
                now = min(now, dis1[c1][k] + dis1[c2][k] + 1 +
                                   (mask1 >> k & 1) + (mask2 >> k & 1));
              if (c1 == c2 && mask1 == mask2)
                num[now] += 1LL * cnt[c1][mask1] * (cnt[c1][mask1] - 1) / 2;
              else
                num[now] += 1LL * cnt[c1][mask1] * cnt[c2][mask2];
            }
  for (int i = 1; i <= N; ++i) {
    for (int j = i + 1; j <= i + 15 && j <= N; ++j) {
      int now = 20;
      for (int k = 0; k < 8; ++k)
        now = min(now, dis1[S[i]][k] + dis1[S[j]][k] + 1 + (id[i] >> k & 1) +
                           (id[j] >> k & 1));
      num[now]--;
      now = min(now, j - i);
      num[now]++;
    }
  }
  int res = 15;
  while (!num[res]) res--;
  printf("%d %lld\n", res, num[res]);
}
int main() {
  work();
  return 0;
}
