#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
char S[100010];
int col[100010], dist1[9][9], dist2[100010][9], mask[100010];
bool vis[9];
int cnt[9][256];
std::vector<int> pos[9];
int main() {
  int n = gi();
  scanf("%s", S + 1);
  memset(dist1, 63, sizeof dist1);
  memset(dist2, 63, sizeof dist2);
  for (int i = 1; i <= n; ++i) pos[col[i] = S[i] - 'a' + 1].push_back(i);
  for (int s = 1; s <= 8; ++s) {
    static int dist0[100010];
    static bool vc[9];
    static std::queue<int> que;
    memset(dist0, 63, sizeof dist0);
    memset(vc, 0, sizeof vc);
    for (int i : pos[s]) dist0[i] = 0, que.push(i);
    vc[s] = 1;
    while (que.size()) {
      int x = que.front();
      que.pop();
      cnk(dist1[s][col[x]], dist0[x]);
      if (!vc[col[x]]) {
        vc[col[x]] = 1;
        for (int i : pos[col[x]])
          if (dist0[i] > dist0[x] + 1) dist0[i] = dist0[x] + 1, que.push(i);
      }
      if (x > 1 && dist0[x - 1] > dist0[x] + 1)
        dist0[x - 1] = dist0[x] + 1, que.push(x - 1);
      if (x < n && dist0[x + 1] > dist0[x] + 1)
        dist0[x + 1] = dist0[x] + 1, que.push(x + 1);
    }
    for (int i = 1; i <= n; ++i)
      dist2[i][s] = dist0[i], mask[i] |= (dist2[i][s] > dist1[s][col[i]])
                                         << s - 1;
  }
  int ans1 = -1;
  long long ans2 = 0;
  auto update = [&](int x, int d = 1) -> void {
    if (x > ans1)
      ans1 = x, ans2 = d;
    else if (x == ans1)
      ans2 += d;
  };
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 15 && i - j > 0; ++j) {
      int d = j;
      for (int k = 1; k <= 8; ++k) cnk(d, dist2[i][k] + dist2[i - j][k] + 1);
      update(d);
    }
    if (i > 16) ++cnt[col[i - 16]][mask[i - 16]];
    for (int j = 1; j <= 8; ++j) {
      int min = 1e9, T = 0;
      for (int k = 1; k <= 8; ++k)
        if (dist2[i][k] + dist1[j][k] + 1 < min)
          min = dist2[i][k] + dist1[j][k] + 1, T = 1 << k - 1;
        else if (dist2[i][k] + dist1[j][k] + 1 == min)
          T |= 1 << k - 1;
      for (int S = 0; S < 1 << 8; ++S)
        if (cnt[j][S]) update(min + !(T & ~S), cnt[j][S]);
    }
  }
  printf("%d %lld\n", ans1, ans2);
  return 0;
}
