#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<pair<int, int> > > adj;
vector<int> sz;
vector<int> dep;
void dfs(int u) {
  sz[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    dep[v] = dep[u] + 1;
    dfs(v);
    sz[u] += sz[v];
  }
}
vector<vector<int> > trie;
vector<int> Dsz;
void mrg(int u, int tu) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    int c = adj[u][i].second;
    if (trie[tu][c] == -1) {
      trie[tu][c] = trie.size();
      trie.push_back(vector<int>(26, -1));
    }
    mrg(v, trie[tu][c]);
  }
}
int intersect(int u, int tu) {
  int ret = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    int c = adj[u][i].second;
    if (trie[tu][c] == -1) continue;
    ret += intersect(v, trie[tu][c]);
  }
  return ret;
}
void solve(int u) {
  int mx = -1, big = -1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    if (mx < sz[v]) {
      mx = sz[v];
      big = v;
    }
  }
  trie.clear();
  trie.push_back(vector<int>(26, -1));
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    if (v == big) continue;
    mrg(v, 0);
  }
  Dsz[dep[u]] += sz[u] - (sz[big] + trie.size() - intersect(big, 0));
}
int main() {
  scanf("%d", &N);
  adj.resize(N);
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    char t;
    scanf("%d %d %c", &u, &v, &t);
    u--;
    v--;
    adj[u].push_back(pair<int, int>(v, t - 'a'));
  }
  sz = vector<int>(N);
  dep = vector<int>(N, 0);
  dfs(0);
  Dsz = vector<int>(N, 0);
  for (int i = 0; i < N; i++) {
    if (adj[i].size() == 0) continue;
    solve(i);
  }
  int mx = -1, mp = -1;
  for (int i = 0; i < N; i++) {
    if (mx < Dsz[i]) {
      mx = Dsz[i];
      mp = i;
    }
  }
  printf("%d\n%d", N - mx, mp + 1);
}
