#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
char s[N];
vector<int> e[8];
int n, dis[8][N], disc[8][8], visc[8], vis[N], mask[N], cnt[8][256];
void bfs(int C) {
  if (e[C].empty()) {
    for (int i = 1; i <= n; i++) dis[C][i] = 1e9;
    return;
  }
  static int q[N];
  int size = 0, times = C + 1;
  for (int i = 0; i < e[C].size(); i++) vis[q[++size] = e[C][i]] = times;
  for (int dep = 1, i = 1; size < n; dep++) {
    int R = size;
    for (; i <= R; i++) {
      int v = q[i];
      if (visc[s[v]] != times) {
        visc[s[v]] = times;
        for (int j = 0; j < e[s[v]].size(); j++) {
          int u = e[s[v]][j];
          if (vis[u] != times) vis[q[++size] = u] = times, dis[C][u] = dep;
        }
      }
      if (v > 1 && vis[v - 1] != times)
        vis[q[++size] = v - 1] = times, dis[C][v - 1] = dep;
      if (v < n && vis[v + 1] != times)
        vis[q[++size] = v + 1] = times, dis[C][v + 1] = dep;
    }
  }
}
int dist(int x, int y) {
  int ans = 1e9;
  for (int i = 0; i < 8; i++) ans = min(ans, dis[i][x] + dis[i][y] + 1);
  return ans;
}
long long calc(int D) {
  long long ans = 0;
  for (int i = 0; i < 8; i++)
    for (int j = i + 1; j < 8; j++) {
      for (int S = 0; S < 256; S++)
        if (cnt[i][S])
          for (int T = 0; T < 256; T++)
            if (cnt[j][T]) {
              int len = 1e9;
              for (int c = 0; c < 8; c++)
                len = min(len, disc[i][c] + disc[j][c] + (S >> c & 1) +
                                   (T >> c & 1) + 1);
              if (len <= D) ans += (long long)cnt[i][S] * cnt[j][T];
            }
    }
  for (int i = 0; i < 8; i++)
    ans += (long long)e[i].size() * (e[i].size() - 1) / 2;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n && j <= i + D; j++)
      if (dist(i, j) > D) ans++;
  return ans;
}
void solve() {
  for (int i = 0; i < 8; i++) e[i].clear();
  scanf("%d%s", &n, s + 1);
  for (int i = 1; i <= n; i++) e[s[i] -= 'a'].push_back(i);
  for (int i = 0; i < 8; i++) bfs(i);
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) disc[i][j] = 1e9;
  for (int j = 0; j < 8; j++)
    for (int i = 1; i <= n; i++) disc[j][s[i]] = min(disc[j][s[i]], dis[j][i]);
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i++) {
    mask[i] = 0;
    for (int j = 0; j < 8; j++)
      if (dis[j][i] > disc[j][s[i]]) mask[i] |= (1 << j);
    cnt[s[i]][mask[i]]++;
  }
  long long last = 0;
  for (int ans1 = 1;; ans1++) {
    long long now = calc(ans1);
    if (now == (long long)n * (n - 1) / 2) {
      printf("%d %lld\n", ans1, now - last);
      break;
    }
    last = now;
  }
}
int main() {
  solve();
  return 0;
}
