#include <bits/stdc++.h>
using namespace std;
const int K = 26;
struct vertex {
  vector<int> next;
  int cnt;
  vertex() : next(K, -1), cnt(1) {}
};
vector<vertex> trie;
vector<vector<pair<int, char>>> graph;
vector<int> sz;
vector<int> height;
void init_dfs(int v, int h = 0) {
  sz[v] = 1;
  height[v] = h;
  for (auto& e : graph[v]) {
    int to = e.first;
    init_dfs(to, h + 1);
    sz[v] += sz[to];
    if (sz[to] > sz[graph[v][0].first]) swap(e, graph[v][0]);
  }
}
vector<int> ans;
void transfuse(int v, vector<vertex>& t, int& last, int state = 0) {
  for (auto& e : graph[v]) {
    int to = e.first;
    int c = e.second - 'a';
    if (t[state].next[c] == -1) {
      t[state].next[c] = last;
      ++last;
    }
    transfuse(to, t, last, t[state].next[c]);
  }
}
void cnt_trie(int state, vector<vertex>& t) {
  for (auto to : t[state].next)
    if (to != -1) {
      cnt_trie(to, t);
      t[state].cnt += t[to].cnt;
    }
}
int count(int stSub, vector<vertex>& subtrie, int stLeader,
          vector<vertex>& trie) {
  int res = 0;
  for (int c = 0; c < K; ++c) {
    if (subtrie[stSub].next[c] == -1) continue;
    if (trie[stLeader].next[c] == -1)
      res += subtrie[subtrie[stSub].next[c]].cnt;
    else
      res +=
          count(subtrie[stSub].next[c], subtrie, trie[stLeader].next[c], trie);
  }
  return res;
}
void dfs(int v) {
  if (graph[v].size() == 0) return;
  int leader = graph[v][0].first;
  vector<vertex> subtrie(sz[v] - sz[leader]);
  int last = 1;
  for (int j = 1; j < graph[v].size(); ++j) {
    int u = graph[v][j].first;
    transfuse(u, subtrie, last);
  }
  cnt_trie(0, subtrie);
  int res = trie[leader].cnt + count(0, subtrie, leader, trie);
  ans[height[v]] += sz[v] - res;
  for (auto& e : graph[v]) dfs(e.first);
}
int main() {
  int n;
  cin >> n;
  sz.resize(n);
  graph.resize(n);
  ans.resize(n);
  height.resize(n);
  trie.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    --u, --v;
    graph[u].push_back(make_pair(v, c));
    trie[u].next[c - 'a'] = v;
  }
  init_dfs(0);
  cnt_trie(0, trie);
  dfs(0);
  int delta = -1;
  int ans_p = -1;
  for (int p = 0; p < n; ++p)
    if (delta < ans[p]) {
      delta = ans[p];
      ans_p = p;
    }
  cout << n - delta << endl << ans_p + 1;
  return 0;
}
