#include <bits/stdc++.h>
using namespace std;
const int mod = int(1e9) + 7;
const long long infLL = 1e15;
const int MX2 = 10100500;
const int MX = 300500;
int e[MX][26];
vector<pair<int, int>> d[MX];
int ans[MX];
int depth[MX];
int check(vector<int> &z) {
  int ans = 0;
  for (int l = 0; l < 26; l++) {
    int cnt = 0;
    for (int i = 0; i < z.size(); i++) {
      if (e[z[i]][l]) cnt++;
    }
    if (cnt < 2) continue;
    ans += cnt - 1;
    vector<int> t;
    for (int i = 0; i < z.size(); i++) {
      if (e[z[i]][l]) t.push_back(e[z[i]][l]);
    }
    ans += check(t);
  }
  return ans;
}
void dfs(int u) {
  vector<int> t;
  for (int i = 0; i < 26; i++) {
    if (e[u][i]) {
      t.push_back(e[u][i]);
      dfs(e[u][i]);
    }
  }
  ans[depth[u]] += check(t) + t.size();
}
void pre_dfs(int u, int pr) {
  for (int i = 0; i < d[u].size(); i++) {
    int v = d[u][i].first;
    if (v == pr) continue;
    e[u][d[u][i].second] = v;
    depth[v] = depth[u] + 1;
    pre_dfs(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    u--;
    v--;
    d[u].push_back({v, c - 'a'});
    d[v].push_back({u, c - 'a'});
  }
  pre_dfs(0, 0);
  dfs(0);
  int r = 0;
  for (int i = 1; i < n; i++) {
    if (ans[i] > ans[r]) r = i;
  }
  cout << n - ans[r] << endl << r + 1 << endl;
  return 0;
}
