#include <bits/stdc++.h>
using namespace ::std;
const int maxn = 3e5 + 7;
struct Trie {
  int ch[26];
} w[maxn], rest[maxn];
int n, res[maxn], sz[maxn], rm, id;
void merge(int u, int v) {
  for (int i = 0; i < 26; i++) {
    if (!w[v].ch[i]) continue;
    if (!rest[u].ch[i]) {
      rest[u].ch[i] = id++;
    } else {
      rm++;
    }
    merge(rest[u].ch[i], w[v].ch[i]);
  }
}
void get_ans(int u, int v) {
  for (int i = 0; i < 26; i++)
    if (rest[u].ch[i] && w[v].ch[i]) {
      rm++;
      get_ans(rest[u].ch[i], w[v].ch[i]);
    }
}
void init(int u) {
  for (int i = 0; i < 26; i++) {
    if (rest[u].ch[i]) {
      init(rest[u].ch[i]);
      rest[u].ch[i] = 0;
    }
  }
}
void dfs(int u, int dep) {
  int mx = 0, mxv = -1;
  sz[u] = 1;
  for (int i = 0; i < 26; i++) {
    if (w[u].ch[i] == 0) continue;
    int v = w[u].ch[i];
    dfs(v, dep + 1);
    sz[u] += sz[v];
    if (sz[v] > mx) {
      mx = sz[v];
      mxv = v;
    }
  }
  if (mxv == -1) return;
  rm = 1;
  id = 2;
  init(1);
  for (int i = 0; i < 26; i++) {
    int v = w[u].ch[i];
    if (v == 0) continue;
    if (v == mxv) continue;
    merge(1, v);
    rm++;
  }
  get_ans(1, mxv);
  res[dep] += rm;
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    char c[5];
    scanf("%d%d%s", &u, &v, c);
    w[u].ch[c[0] - 'a'] = v;
  }
  dfs(1, 1);
  int ans = 1;
  for (int i = 1; i <= n; i++)
    if (res[ans] < res[i]) ans = i;
  printf("%d\n%d\n", n - res[ans], ans);
}
int main() {
  solve();
  return 0;
}
