#include <bits/stdc++.h>
using namespace std;
const int maxn = 345678, maxc = 26;
int a[maxn][maxc], temp[maxn][maxc], size[maxn], res[maxn];
int n, m;
void merge(int k, int root) {
  for (int i = 0; i < maxc; i++)
    if (a[k][i]) {
      if (!temp[root][i]) {
        temp[root][i] = m++;
        for (int j = 0; j < maxc; j++) temp[temp[root][i]][j] = 0;
      }
      merge(a[k][i], temp[root][i]);
    }
}
int countSame(int k, int root) {
  int total = 1;
  for (int i = 0; i < maxc; i++)
    if (a[k][i] && temp[root][i]) total += countSame(a[k][i], temp[root][i]);
  return total;
}
void dfs(int k, int d) {
  size[k] = 1;
  int argmx = -1;
  for (int i = 0; i < maxc; i++)
    if (a[k][i]) {
      dfs(a[k][i], d + 1);
      size[k] += size[a[k][i]];
      if (argmx == -1 || size[a[k][i]] > size[a[k][argmx]]) argmx = i;
    }
  if (argmx != -1) {
    m = 1;
    for (int i = 0; i < maxc; i++) temp[0][i] = 0;
    for (int i = 0; i < maxc; i++)
      if (a[k][i] && i != argmx) {
        merge(a[k][i], 0);
      }
    int count = countSame(a[k][argmx], 0);
    res[d] += size[k] - (size[a[k][argmx]] + m - count);
  }
}
int main() {
  scanf("%d", &n);
  memset(a, 0, sizeof a);
  for (int i = 0; i < n; i++) {
    int u, v;
    char x;
    scanf("%d %d %c", &u, &v, &x);
    a[u][x - 'a'] = v;
  }
  memset(res, 0, sizeof res);
  dfs(1, 1);
  int ans = n, arg = 0;
  for (int i = 1; i <= n; i++)
    if (n - res[i] < ans) {
      ans = n - res[i];
      arg = i;
    }
  printf("%d\n%d\n", ans, arg);
  return 0;
}
