#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 3e5 + 5, K = 30;
int tam[N] = {1}, g[N][K], _g[N][K];
vector<int> v;
int res[N];
pair<int, int> merge(int a, int b) {
  if (!a) return pair<int, int>(b, 0);
  if (!b) return pair<int, int>(a, 0);
  int r = 0;
  v.push_back(a);
  for (int i = 0; i < K; i++) {
    if (g[a][i] and g[b][i]) {
      r++;
      pair<int, int> p = merge(g[a][i], g[b][i]);
      g[a][i] = p.first;
      r += p.second;
    } else if (g[b][i]) {
      g[a][i] = g[b][i];
    }
  }
  return pair<int, int>(a, r);
}
void go(int at, int d) {
  int r = 0;
  for (int i = 0; i < K; i++) {
    int next = g[at][i];
    if (next) {
      r++;
      go(next, d + 1);
      tam[at] += tam[next];
    }
  }
  v.clear();
  v.push_back(at);
  int u = 0;
  for (int i = 0; i < K; i++) {
    int next = g[at][i];
    pair<int, int> p = merge(u, next);
    u = p.first;
    r += p.second;
  }
  for (int i = 0; i < (int)v.size(); i++)
    for (int j = 0; j < K; j++) g[v[i]][j] = _g[v[i]][j];
  res[d] += r;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    g[a][c - 'a'] = b;
    _g[a][c - 'a'] = b;
  }
  go(1, 1);
  int ans = 0;
  for (int i = 0; i < N; i++)
    if (res[i] > res[ans]) ans = i;
  cout << n - res[ans] << endl;
  cout << ans << endl;
  return 0;
}
