#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5, SIGMA = 26;
int adj[MAX_N + 1][SIGMA], d[MAX_N + 1], ans[MAX_N + 1], cnt[MAX_N + 1],
    sz[MAX_N + 1];
queue<pair<int, int> > Q;
int merge(int x, int y) {
  int ret = 0;
  for (int i = (0), i_ = (SIGMA); i < i_; ++i) {
    int &u = adj[x][i], v = adj[y][i];
    if (!v) continue;
    if (u)
      ret += merge(u, v);
    else {
      u = v;
      Q.push(pair<int, int>(x, i));
      ret += sz[v];
    }
  }
  return ret;
}
void retrace() {
  while (!Q.empty()) {
    pair<int, int> p = Q.front();
    Q.pop();
    adj[p.first][p.second] = 0;
  }
}
void dfs(int u) {
  int big = 0, mx = 0;
  sz[u] = 1;
  ++cnt[d[u]];
  for (int i = (0), i_ = (SIGMA); i < i_; ++i) {
    int v = adj[u][i];
    if (!v) continue;
    d[v] = d[u] + 1;
    dfs(v);
    sz[u] += sz[v];
    if (sz[v] > mx) {
      mx = sz[v];
      big = v;
    }
  }
  if (!big) {
    ++ans[d[u]];
    return;
  }
  int s = mx;
  for (int i = (0), i_ = (SIGMA); i < i_; ++i) {
    int v = adj[u][i];
    if (v && v != big) s += merge(big, v);
  }
  ans[d[u]] += s;
  retrace();
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = (0), i_ = (n - 1); i < i_; ++i) {
    int u, v;
    char x;
    cin >> u >> v >> x;
    adj[u][x - 'a'] = v;
  }
  d[1] = 1;
  dfs(1);
  int max_d = *max_element(d + 1, d + n + 1);
  for (int i = (2), i_ = (max_d - 1); i <= i_; ++i) {
    cnt[i] += cnt[i - 1];
    ans[i] += cnt[i - 1];
  }
  int* x = min_element(ans + 1, ans + max_d);
  cout << *x << endl << x - ans << endl;
  return 0;
}
