#include <bits/stdc++.h>
using namespace std;
const int MAX = 300010;
int n;
int maxx;
int node[2 * MAX][30];
int cau[MAX];
int site;
int other;
void in() {
  scanf("%d", &n);
  int a, b;
  char c;
  for (int i = 1; i < n; i++) {
    scanf("%d %d %c", &a, &b, &c), node[a][c - 'a'] = b;
  }
}
int w = 1;
int mix(int x, int y) {
  if (x == 0 || y == 0) return x + y;
  int now = ++other;
  site++;
  for (int i = 0; i < 26; i++) node[now][i] = mix(node[x][i], node[y][i]);
  return now;
}
void dfs(int x, int deep) {
  other = n + 1;
  int now = other;
  site = 0;
  for (int i = 0; i < 26; i++) now = mix(now, node[x][i]);
  cau[deep] += site;
  for (int i = 0; i < 26; i++)
    if (node[x][i] > 0) dfs(node[x][i], deep + 1);
}
void work() {
  dfs(1, 1);
  maxx = 1;
  for (int i = 1; i <= n; i++)
    if (n - cau[maxx] > n - cau[i]) maxx = i;
}
void out() {
  printf("%d\n", n - cau[maxx]);
  printf("%d\n", maxx);
}
int main() {
  in();
  work();
  out();
  return 0;
}
