#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int S = 260;
int n, ans, now, inf;
long long cnt;
int dp[N][10], f[10][10], d[N], w[N];
long long c[10][S];
bool vis[10];
char s[N];
queue<int> q;
void bfs(int c) {
  int i, k;
  memset(d, 0x3f, sizeof(d));
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) q.pop();
  vis[c] = 1;
  for (i = 1; i <= n; i++)
    if (s[i] - 'a' == c) d[i] = 0, q.push(i);
  while (!q.empty()) {
    k = q.front();
    q.pop();
    if (!vis[s[k] - 'a']) {
      vis[s[k] - 'a'] = 1;
      for (i = 1; i <= n; i++)
        if (s[i] == s[k] && d[i] > n) d[i] = d[k] + 1, q.push(i);
    }
    if (k > 1 && d[k - 1] > n) d[k - 1] = d[k] + 1, q.push(k - 1);
    if (k < n && d[k + 1] > n) d[k + 1] = d[k] + 1, q.push(k + 1);
  }
  for (i = 1; i <= n; i++) dp[i][c] = d[i];
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  scanf("%s", s + 1);
  memset(dp, 0x3f, sizeof(dp));
  inf = dp[0][0];
  for (i = 0; i < 8; i++) bfs(i);
  memset(f, 0x3f, sizeof(f));
  for (i = 1; i <= n; i++)
    for (j = 0; j < 8; j++) f[s[i] - 'a'][j] = min(f[s[i] - 'a'][j], dp[i][j]);
  for (i = 1; i <= n; i++)
    for (j = 0; j < 8; j++)
      if (dp[i][j] > f[s[i] - 'a'][j]) w[i] |= (1 << j);
  for (i = 1; i <= n; i++) {
    for (j = max(1, i - 15); j < i; j++) {
      now = i - j;
      for (k = 0; k < 8; k++) now = min(now, dp[i][k] + dp[j][k] + 1);
      if (now == ans) cnt++;
      if (now > ans) ans = now, cnt = 1;
    }
    j = i - 16;
    if (j >= 1) c[s[j] - 'a'][w[j]]++;
    for (j = 0; j < 8; j++)
      for (k = 0; k < 256; k++) {
        if (!c[j][k]) continue;
        now = inf;
        for (l = 0; l < 8; l++) {
          now = min(now, dp[i][l] + f[j][l] + 1 + ((k >> l) & 1));
        }
        if (now == inf) continue;
        if (now == ans) cnt += c[j][k];
        if (now > ans) ans = now, cnt = c[j][k];
      }
  }
  printf("%d %I64d\n", ans, cnt);
  return 0;
}
