#include <bits/stdc++.h>
using namespace std;
int n, x, y, node[2 * 300010][26], tot[300010], cnt, num, ans;
char ch;
int add(int u, int v) {
  if (!u || !v) return u + v;
  int z = ++num;
  cnt++;
  for (int i = 0; i < 26; i++) node[z][i] = add(node[u][i], node[v][i]);
  return z;
}
void dfs(int v, int dep) {
  if (!v) return;
  num = n + 1;
  cnt = 0;
  int rt = num;
  for (int i = 0; i < 26; i++) rt = add(rt, node[v][i]);
  tot[dep] += cnt;
  for (int i = 0; i < 26; i++) dfs(node[v][i], dep + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d %c", &x, &y, &ch);
    node[x][ch - 'a'] = y;
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++)
    if (tot[i] > tot[ans]) ans = i;
  printf("%d\n%d", n - tot[ans], ans);
}
