#include <bits/stdc++.h>
using namespace std;
const int Max_N(1000050);
const int Max_K(16);
int N, K, F[Max_K][Max_N], G[Max_K][Max_K];
char S[Max_N];
void prepareFG() {
  deque<int> Q;
  int u, v;
  for (int C = 0; C < K; ++C) {
    memset(F[C], 0X3F, sizeof(F[C])), memset(G[C], 0X3F, sizeof(G[C]));
    for (u = 1; u <= N; ++u)
      if (S[u] == C) F[C][u] = 0, Q.push_front(u);
    while (Q.size()) {
      u = Q.front(), Q.pop_front();
      if (u <= N) {
        if ((v = u - 1) >= 1 && F[C][v] > F[C][u] + 1)
          F[C][v] = F[C][u] + 1, Q.push_back(v);
        if ((v = u + 1) <= N && F[C][v] > F[C][u] + 1)
          F[C][v] = F[C][u] + 1, Q.push_back(v);
        if (G[C][S[u]] > F[C][u])
          G[C][S[u]] = F[C][u], Q.push_front(N + (1 + S[u]));
      } else {
        u -= (N + 1);
        for (v = 1; v <= N; ++v)
          if (S[v] == u && F[C][v] > G[C][u] + 1)
            F[C][v] = G[C][u] + 1, Q.push_back(v);
      }
    }
  }
}
long long int Ans[2 * Max_K + 5];
int Limit, S1, S2, Cnt[Max_K][1 << (Max_K >> 1)][1 << (Max_K >> 1)],
    Cnt2[Max_K];
void work() {
  for (int i = 1; i <= K; ++i)
    if (i == K || (1 << (K - i)) <= (1 << i) * K) {
      Limit = i;
      break;
    }
  S1 = (1 << Limit), S2 = (1 << (K - Limit));
  for (int c = 0; c < K; ++c) {
    Cnt2[c] = 0;
    for (int i = 0; i < S1; ++i)
      for (int j = 0; j < S2; ++j) Cnt[c][i][j] = 0;
  }
  memset(Ans, 0, sizeof(Ans));
  for (int u = 1, v, B; u <= N; ++u) {
    for (int v = u - 1, l; v >= u - (2 * K - 1) && v >= 1; --v) {
      l = u - v;
      for (int c = 0; c < K; ++c) l = min(l, F[c][v] + 1 + F[c][u]);
      ++Ans[l];
    }
    if ((v = u - 2 * K) >= 1) {
      B = 0;
      for (int c = 0; c < K; ++c) B += (1 << c) * (F[c][v] - G[c][S[v]]);
      int _S1 = (B & (S1 - 1)), _S2 = (B >> Limit);
      for (int S0 = _S2;; S0 = ((S0 - 1) & _S2)) {
        ++Cnt[S[v]][_S1][S0];
        if (!S0) break;
      }
      ++Cnt2[S[v]];
    }
    for (int Sv = 0, D; Sv < K; ++Sv) {
      D = 0X3F3F3F3F;
      for (int c = 0; c < K; ++c) D = min(D, F[c][u] + 1 + G[c][Sv]);
      B = 0;
      for (int c = 0; c < K; ++c) B += (1 << c) * (F[c][u] + 1 + G[c][Sv] == D);
      int _S1 = (B & (S1 - 1)), _S2 = (B >> Limit);
      int QAQ = 0;
      for (int S0 = S1 - 1 - _S1;; S0 = ((S0 - 1) & (S1 - 1 - _S1))) {
        QAQ += Cnt[Sv][_S1 | S0][_S2];
        if (!S0) break;
      }
      if (Cnt2[Sv] - QAQ) Ans[D] += Cnt2[Sv] - QAQ;
      if (QAQ) Ans[D + 1] += QAQ;
    }
  }
  for (int i = 0; i <= 2 * K - 1; ++i)
    if (Ans[i]) ++Ans[2 * K];
  for (int i = 2 * K - 1; i >= 0; --i)
    if (Ans[i]) {
      printf("%d %lld\n", i, Ans[i]);
      break;
    }
}
int main() {
  int Case;
  Case = 1;
  while (Case--) {
    scanf("%d", &N);
    scanf("%s", S + 1), N = strlen(S + 1), K = 0;
    for (int i = 1; i <= N; ++i) K = max(K, static_cast<int>(S[i] -= 'a') + 1);
    prepareFG();
    work();
  }
  return 0;
}
