#include <bits/stdc++.h>
using namespace std;
const int N = 600100;
const int M = 1000010;
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ans;
}
long long qpow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b /= 2;
  }
  return ans;
}
int to[N][26], d[N], siz[N], tot, n, cnt[N];
int mer(int x, int y) {
  if (x == 0 || y == 0) return x | y;
  int t = ++tot;
  siz[t] = 1;
  for (int i = 0; i < 26; i++) {
    to[t][i] = mer(to[y][i], to[x][i]);
    siz[t] += siz[to[t][i]];
  }
  return t;
}
void dfs(int x, int dep) {
  d[x] = dep;
  siz[x] = 1;
  for (int i = 0; i < 26; i++) {
    if (to[x][i] == 0) continue;
    dfs(to[x][i], dep + 1);
    siz[x] += siz[to[x][i]];
  }
  cnt[d[x]] += siz[x];
  tot = n;
  int p = 0;
  for (int i = 0; i < 26; i++) p = mer(p, to[x][i]);
  cnt[d[x]] -= max(siz[p], 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    char s[10];
    scanf("%d%d%s", &u, &v, s);
    to[u][s[0] - 'a'] = v;
  }
  dfs(1, 1);
  int ans = 0, p = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > ans) {
      ans = cnt[i];
      p = i;
    }
  }
  printf("%d\n%d", n - ans, p);
}
