#include <bits/stdc++.h>
using namespace std;
int n;
char a[100010];
vector<int> points[10];
int dis[100010][10];
int dch[10][10];
int cnt[10][300];
int mask[100010];
int ans;
long long ans2;
void update(int x, int tot) {
  if (x == ans) ans2 += tot;
  if (x > ans) {
    ans = x;
    ans2 = tot;
  }
}
void bfs(int ch) {
  queue<int> q;
  for (vector<int>::iterator i = points[ch].begin(); i != points[ch].end(); i++)
    q.push(*i);
  for (int i = 1; i <= n; i++)
    if (a[i] == ch + 96)
      dis[i][ch] = 0;
    else
      dis[i][ch] = 0x3f3f3f3f;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (dis[x - 1][ch] == 0x3f3f3f3f) {
      dis[x - 1][ch] = dis[x][ch] + 1;
      q.push(x - 1);
    }
    if (dis[x + 1][ch] == 0x3f3f3f3f) {
      dis[x + 1][ch] = dis[x][ch] + 1;
      q.push(x + 1);
    }
  }
}
void add(int pos) { cnt[a[pos] - 96][mask[pos]]++; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf(" %c", &a[i]);
    points[a[i] - 96].push_back(i);
  }
  for (int ch = 1; ch <= 8; ch++) bfs(ch);
  memset(dch, 0x3f, sizeof(dch));
  for (int i = 1; i <= 8; i++) dch[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= 8; i++)
      for (int j = 1; j <= 8; j++)
        dch[i][j] = min(dch[i][j], dis[k][i] + dis[k][j]);
  for (int k = 1; k <= 8; k++)
    for (int i = 1; i <= 8; i++)
      for (int j = 1; j <= 8; j++)
        dch[i][j] = min(dch[i][j], dch[i][k] + dch[k][j] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 8; j++)
      for (int ch = 1; ch <= 8; ch++)
        dis[i][ch] = min(dis[i][ch], dis[i][j] + dch[j][ch] + 1);
  for (int i = 1; i <= n; i++)
    for (int ch = 1; ch <= 8; ch++)
      mask[i] |= (dis[i][ch] - dch[a[i] - 96][ch]) << (ch - 1);
  for (int r = 1; r <= n; r++)
    for (int l = max(1, r - 15); l < r; l++) {
      int minf = r - l;
      for (int ch = 1; ch <= 8; ch++)
        minf = min(minf, dis[l][ch] + dis[r][ch] + 1);
      update(minf, 1);
    }
  for (int i = 17, j = 1; i <= n; i++, j++) {
    add(j);
    for (int ch = 1; ch <= 8; ch++)
      for (int st = 0; st <= 255; st++) {
        if (cnt[ch][st]) {
          int fuck = 0x3f3f3f3f;
          for (int sb = 1; sb <= 8; sb++)
            fuck = min(fuck,
                       dch[ch][sb] + dis[i][sb] + (((st) >> (sb - 1)) & 1) + 1);
          update(fuck, cnt[ch][st]);
        }
      }
  }
  printf("%d %lld\n", ans, ans2);
  return 0;
}
