#include <bits/stdc++.h>
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
using namespace std;
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
const long long infll = 1e18 + 3;
const int inf = 1009000999;
const double eps = 1e-7;
const int maxn = 2e6 + 46;
const int baseint = 1000200013;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
const long long mod = 1e9 + 7;
int g[maxn][30];
int sz[maxn];
int lvl[maxn];
int ans[maxn];
bool gl[maxn];
int n;
void dfsInit(int v, int l) {
  sz[v]++;
  lvl[v] = l;
  int mx = 0;
  for (int i = 0; i < 30; i++) {
    if (g[v][i] != 0) dfsInit(g[v][i], l + 1);
    sz[v] += sz[g[v][i]];
  }
}
int last, lvlGo, stt;
void go(int v, int u) {
  if (last > n * 3 || v == u) {
    cout << "Kek\n";
    cout << stt << "\n";
    cout << (last > n * 3) << " " << (v == u);
    exit(0);
  }
  for (int i = 0; i < 30; i++) {
    if (g[u][i] != 0) {
      if (!g[v][i]) {
        last++;
        g[v][i] = last;
      } else
        ans[lvlGo]--;
      go(g[v][i], g[u][i]);
    }
  }
}
void godel(int v, int u) {
  for (int i = 0; i < 30; i++) {
    if (g[v][i] > n) g[v][i] = 0;
    if (g[u][i] != 0) godel(g[v][i], g[u][i]);
  }
}
void dfs(int v) {
  int st = 0;
  for (int i = 0; i < 30; i++)
    if (g[v][i] > 0 && g[v][i] <= n) {
      dfs(g[v][i]);
      ans[lvl[v] + 1]--;
      if (sz[st] < sz[g[v][i]]) st = g[v][i];
    }
  if (v == 1) v = 1;
  stt = v;
  last = n;
  lvlGo = lvl[v] + 1;
  for (int i = 0; i < 30; i++)
    if (g[v][i] && g[v][i] != st) go(st, g[v][i]);
  for (int i = 0; i < 30; i++)
    if (g[v][i] && g[v][i] != st) godel(st, g[v][i]);
  for (int i = n + 1; i <= last; i++)
    for (int j = 0; j < 30; j++) g[i][j] = 0;
}
void solve() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int v, u;
    char c;
    cin >> v >> u >> c;
    c -= 'a';
    g[v][c] = u;
    gl[u] = 1;
  }
  for (int i = 1; i <= n; i++) ans[i] = n;
  int st = 1;
  while (gl[st]) st++;
  dfsInit(st, 0);
  dfs(st);
  int b = 1;
  for (int i = 2; i <= n; i++)
    if (ans[i] < ans[b]) b = i;
  cout << ans[b] << "\n" << b;
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
