#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int md = 0;
int ans[maxn];
int g[maxn][26];
int merge(const vector<int>& a) {
  int res = (int)(a).size() - 1;
  vector<int> b;
  for (int i = 0; i < 26; i++) {
    b.clear();
    for (auto u : a) {
      if (g[u][i]) {
        b.emplace_back(g[u][i]);
      }
    }
    if ((int)(b).size() > 1) res += merge(b);
  }
  return res;
}
void dfs(int v, int d = 1) {
  vector<int> tmp;
  md = max(md, d);
  for (int i = 0; i < 26; i++) {
    if (g[v][i] == 0) continue;
    tmp.emplace_back(g[v][i]);
  }
  int res = merge(tmp) + 1;
  ans[d] += res;
  for (int i = 0; i < 26; i++) {
    if (g[v][i] == 0) continue;
    dfs(g[v][i], d + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    char ch;
    cin >> u >> v >> ch;
    g[u][ch - 'a'] = v;
  }
  dfs(1);
  int p = 1;
  for (int i = 1; i <= md; ++i) {
    if (ans[p] < ans[i]) {
      p = i;
    }
  }
  cout << n - ans[p] << "\n" << p << "\n";
  return 0;
}
