#include <bits/stdc++.h>
using namespace std;
int n, nn, cnt, mxd, G[(300000 + 5) << 1][(26 + 5)], Minus[(300000 + 5)];
int Merge(int x, int y) {
  if (!x || !y) return x | y;
  int now = ++nn;
  ++cnt;
  for (int i = (0); i <= (int)(25); ++i) G[now][i] = Merge(G[x][i], G[y][i]);
  return now;
}
void Dfs(int now, int dep) {
  nn = n + 1;
  mxd = max(mxd, dep);
  memset(G[nn], 0, sizeof(G[nn]));
  cnt = 0;
  int rt = nn;
  for (int i = (0); i <= (int)(25); ++i) rt = Merge(rt, G[now][i]);
  Minus[dep] += cnt;
  for (int i = (0); i <= (int)(25); ++i)
    if (G[now][i]) Dfs(G[now][i], dep + 1);
}
int main() {
  int u, v;
  char rs[5];
  scanf("%d", &n);
  for (int i = (1); i <= (int)(n - 1); ++i) {
    scanf("%d%d%s", &u, &v, rs);
    G[u][rs[0] - 'a'] = v;
  }
  Dfs(1, 1);
  int Max = 0, id = 0;
  for (int i = (1); i <= (int)(mxd); ++i)
    if (Max < Minus[i]) {
      Max = Minus[i];
      id = i;
    }
  printf("%d\n%d\n", n - Max, id);
  return 0;
}
