#include <bits/stdc++.h>
using namespace std;
const long long oo = 0x3f3f3f3f3f3f3f3fll;
const int LGN = 25;
const int MOD = 1e9 + 7;
const int N = 3e5 + 5;
int n, adj[N][26], dep[N];
vector<pair<int, int> > T[N];
vector<int> depset[N];
int sub[N], big[N];
void dfs1(int u = 1, int p = 0, int d = 1) {
  dep[u] = d;
  depset[d].push_back(u);
  sub[u] = 1;
  for (pair<int, int> e : T[u])
    if (e.first != p) {
      int v = e.first;
      adj[u][e.second] = v;
      dfs1(v, u, d + 1);
      sub[u] += sub[v];
      if (sub[big[u]] < sub[v]) big[u] = v;
    }
}
int ans[N], depans[N];
vector<pair<int, int> > undo;
int merge(int u, int v) {
  int ans = 0;
  for (long long c = 0, __R = 25; c <= __R; c++)
    if (adj[v][c]) {
      if (adj[u][c])
        ans += merge(adj[u][c], adj[v][c]);
      else {
        ans += sub[adj[v][c]];
        adj[u][c] = adj[v][c];
        undo.emplace_back(u, c);
      }
    }
  return ans;
}
void dfs2(int u = 1) {
  if (!big[u]) {
    ans[u] = 1;
    depans[dep[u]]++;
    return;
  }
  for (long long c = 0, __R = 25; c <= __R; c++)
    if (adj[u][c]) dfs2(adj[u][c]);
  ans[u] = sub[big[u]];
  for (long long c = 0, __R = 25; c <= __R; c++)
    if (adj[u][c] && adj[u][c] != big[u]) {
      ans[u] += merge(big[u], adj[u][c]);
    }
  depans[dep[u]] += ans[u];
  for (pair<int, int> e : undo) adj[e.first][e.second] = 0;
  undo.clear();
}
int main() {
  std::ios::sync_with_stdio(false);
  scanf("%d", &(n));
  for (long long i = 2, __R = n; i <= __R; i++) {
    int u, v;
    scanf("%d%d", &(u), &(v));
    char c[2];
    scanf("%s", c);
    T[u].emplace_back(v, c[0] - 'a');
    T[v].emplace_back(u, c[0] - 'a');
  }
  dfs1();
  dfs2();
  int depsum = 0;
  int ans = oo, p;
  for (long long d = 1, __R = n; d <= __R; d++) {
    depsum += depset[d - 1].size();
    int alt = depsum + depans[d];
    if (alt < ans) ans = alt, p = d;
  }
  printf("%d\n%d\n", ans, p);
  return 0;
}
