#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int child[N + 5][27];
int dep;
vector<int> child_n[N + 5];
int si[N + 5];
int depth[N + 5];
int ans_p[N + 5];
int n;
vector<pair<int, int> > new_edge;
int po;
void merge(int v1, int v2) {
  po++;
  for (auto next_n : child_n[v2]) {
    if (child[v1][next_n] == 0) {
      new_edge.push_back(pair<int, int>(v1, next_n));
      child[v1][next_n] = child[v2][next_n];
    } else {
      merge(child[v1][next_n], child[v2][next_n]);
    }
  }
}
int get_ans(int now) {
  int ma = -1;
  int max_child = 0;
  for (auto next_n : child_n[now]) {
    int next = child[now][next_n];
    if (si[next] > ma) {
      ma = si[next];
      max_child = next;
    }
  }
  if (ma == -1) return 0;
  po = 1;
  for (auto next_n : child_n[now]) {
    int next = child[now][next_n];
    if (next != max_child) merge(max_child, next);
  }
  for (auto next2 : new_edge) {
    child[next2.first][next2.second] = 0;
  }
  new_edge.clear();
  return po;
}
void dfs(int now) {
  si[now] = 1;
  dep = max(dep, depth[now]);
  for (auto next_n : child_n[now]) {
    int next = child[now][next_n];
    depth[next] = depth[now] + 1;
    dfs(next);
    si[now] += si[next];
  }
  ans_p[depth[now]] += get_ans(now);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int v1, v2;
    char ad[2];
    scanf("%d %d %s", &v1, &v2, ad);
    child_n[v1].push_back(ad[0] - 'a');
    child[v1][ad[0] - 'a'] = v2;
  }
  depth[1] = 1;
  dfs(1);
  int ans = 1;
  for (int i = 2; i <= dep; i++) {
    if (n - ans_p[ans] > n - ans_p[i]) ans = i;
  }
  printf("%d\n%d", n - ans_p[ans], ans);
  return 0;
}
