#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
int tr[300105 * 2][26], cnt, cur, ans[300105];
int mg(int x, int y) {
  if (x == 0) return y;
  if (y == 0) return x;
  int z = ++cur;
  ++cnt;
  for (int(j) = 0; (j) < (int)(26); (j)++) tr[z][j] = mg(tr[x][j], tr[y][j]);
  return z;
}
void dfs(int x, int dp) {
  cnt = 0;
  cur = n;
  int rt = ++cur;
  for (int(j) = 0; (j) < (int)(26); (j)++)
    if (tr[x][j]) rt = mg(rt, tr[x][j]);
  ans[dp] += cnt;
  for (int(j) = 0; (j) < (int)(26); (j)++)
    if (tr[x][j]) dfs(tr[x][j], dp + 1);
}
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (int)(n - 1); (i)++) {
    int u, v;
    char ope[2];
    scanf("%d%d%s", &u, &v, ope);
    tr[u][ope[0] - 'a'] = v;
  }
  dfs(1, 1);
  int w = -1;
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (w == -1 || ans[i] > ans[w]) {
      w = i;
    }
  printf("%d\n%d\n", n - ans[w], w);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
