#include <bits/stdc++.h>
using namespace std;
char s[100005];
int a[100005], n;
int dis[100005][8], dist[8][8], mask[100005], cnt[8][256];
struct node {
  int a, b;
};
queue<node> q;
inline node make(int a, int b) {
  node tp;
  tp.a = a;
  tp.b = b;
  return tp;
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  scanf("%s", s);
  for (i = 1; i <= n; i++) {
    a[i] = s[i - 1] - 'a';
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 8; j++) {
      if (j == a[i]) {
        q.push(make(i, j));
        dis[i][j] = 0;
      } else {
        dis[i][j] = 100000;
      }
    }
  }
  memset(dist, 0x2f, sizeof(dist));
  while (!q.empty()) {
    node tp = q.front();
    q.pop();
    int st = tp.a, b = tp.b;
    if (st + 1 <= n && dis[st + 1][b] > dis[st][b] + 1) {
      dis[st + 1][b] = dis[st][b] + 1;
      q.push(make(st + 1, b));
    }
    if (st - 1 >= 1 && dis[st - 1][b] > dis[st][b] + 1) {
      dis[st - 1][b] = dis[st][b] + 1;
      q.push(make(st - 1, b));
    }
    if (dis[st][b] < dist[a[st]][b]) {
      dist[a[st]][b] = dis[st][b];
      for (i = 1; i <= n; i++) {
        if (a[i] == a[st] && dis[i][b] > dist[a[st]][b] + 1) {
          dis[i][b] = dist[a[st]][b] + 1;
          q.push(make(i, b));
        }
      }
    }
  }
  int ans = 0;
  long long num = 0;
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= min(i + 15, n); j++) {
      int tp = j - i;
      for (k = 0; k < 8; k++) {
        tp = min(tp, dis[i][k] + dis[j][k] + 1);
      }
      if (tp > ans) {
        ans = tp;
        num = 1;
      } else {
        if (tp == ans) {
          num++;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    mask[i] = 0;
    for (j = 0; j < 8; j++) {
      if (dis[i][j] == dist[a[i]][j] + 1) {
        mask[i] += (1 << j);
      }
    }
    for (j = 0; j < 8; j++) {
      for (k = 0; k <= 255; k++) {
        if (cnt[j][k] == 0) {
          continue;
        }
        int ap = 100000;
        for (l = 0; l < 8; l++) {
          int tp = dist[a[i]][l] + dist[j][l] + 1;
          if ((1 << l) & k) {
            tp++;
          }
          if ((1 << l) & mask[i]) {
            tp++;
          }
          ap = min(ap, tp);
        }
        if (ap > ans) {
          ans = ap;
          num = cnt[j][k];
        } else {
          if (ap == ans) {
            num += cnt[j][k];
          }
        }
      }
    }
    if (i - 15 > 0) {
      cnt[a[i - 15]][mask[i - 15]]++;
    }
  }
  printf("%d %I64d\n", ans, num);
  return 0;
}
