#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50, maxm = 8, inf = 1e9;
int n, mx, a[maxn], d1[maxn][maxm], d2[maxm][maxm], cnt[maxm][1 << maxm],
    S[maxn];
long long ans;
queue<pair<int, int> > q;
int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return x;
}
void init(int c) {
  for (int i = 1; i <= n; i++)
    if (a[i] == c) q.push({i, 0});
  while (!q.empty()) {
    int t = q.front().first, d = q.front().second;
    q.pop();
    if (d1[t][c] > d) {
      d1[t][c] = d;
      if (t > 1) q.push({t - 1, d + 1});
      if (t < n) q.push({t + 1, d + 1});
    }
  }
}
void update(int x, int k) {
  if (x > mx)
    mx = x, ans = k;
  else if (x == mx)
    ans += k;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = getchar() - 'a';
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++) d1[i][j] = inf;
  for (int i = 0; i < 8; i++)
    for (int j = 0; j < 8; j++) d2[i][j] = inf;
  for (int i = 0; i < 8; i++) init(i);
  for (int k = 1; k <= n; k++)
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 8; j++) d2[i][j] = min(d2[i][j], d1[k][i] + d1[k][j]);
  for (int k = 0; k < 8; k++)
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 8; j++)
        d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j] + 1);
  for (int k = 0; k < 8; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 0; j < 8; j++)
        d1[i][j] = min(d1[i][j], d1[i][k] + 1 + d2[k][j]);
  for (int i = 1; i <= n; i++)
    for (int j = max(i - 15, 1); j < i; j++) {
      int mn = i - j;
      for (int k = 0; k < 8; k++) mn = min(mn, d1[i][k] + d1[j][k] + 1);
      update(mn, 1);
    }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      if (d1[i][j] == d2[a[i]][j] + 1) S[i] |= 1 << j;
  for (int i = 17; i <= n; i++) {
    cnt[a[i - 16]][S[i - 16]]++;
    for (int c = 0; c < 8; c++) {
      for (int T = 0; T < 256; T++) {
        if (!cnt[c][T]) continue;
        int mn = inf;
        for (int k = 0; k < 8; k++)
          mn = min(mn, d1[i][k] + d2[c][k] + (T >> k & 1) + 1);
        update(mn, cnt[c][T]);
      }
    }
  }
  printf("%d %lld\n", mx, ans);
  return 0;
}
