#include <bits/stdc++.h>
using namespace std;
long long head[300010], len[300010], dep[300010], c[300010][26];
long long n, ans[300010], tot, Nodenum, ver[600010], Next[600010];
char ch[10], edge[600010];
inline void addEdge(long long u, long long v) {
  ver[++tot] = v;
  edge[tot] = ch[0];
  Next[tot] = head[u];
  head[u] = tot;
}
long long merge(long long a, long long b) {
  if (!a || !b) return a | b;
  long long x = ++Nodenum;
  len[x] = 1;
  for (long long i = 0; i < 26; i++) {
    c[x][i] = merge(c[a][i], c[b][i]);
    len[x] += len[c[x][i]];
  }
  return x;
}
void dfs(long long x, long long fa) {
  len[x] = 1;
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = ver[i], z = edge[i];
    if (y != fa) {
      dep[y] = dep[x] + 1;
      c[x][z - 'a'] = y;
      dfs(y, x);
      len[x] += len[y];
    }
  }
  ans[dep[x]] += len[x];
  Nodenum = n;
  long long p = 0;
  for (long long i = 0; i < 26; i++) p = merge(p, c[x][i]);
  ans[dep[x]] -= max(len[p], (long long)1);
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; i++) {
    long long u, v;
    scanf("%lld%lld%s", &u, &v, ch);
    addEdge(u, v);
    addEdge(v, u);
  }
  dfs(1, 0);
  long long res = 0;
  for (long long i = 0; i < n; i++)
    if (ans[i] > ans[res]) res = i;
  printf("%lld\n%lld", n - ans[res], res + 1);
}
