#include <bits/stdc++.h>
struct node {
  int c;
  node *fii[26];
  node() {
    c = 0;
    for (int i = 0; i < 26; i++) fii[i] = NULL;
  }
} * root;
struct myc {
  int x;
  char y;
  myc(int _x, char _y) {
    x = _x;
    y = _y;
  }
};
int cost;
std::vector<myc> g[300009];
int t[300009], s[300009], fiuMare[300009];
int h[300009], ans[300009];
void schema(node *p, int x) {
  for (auto y : g[x])
    if (y.x != t[x]) {
      if (p->fii[y.y - 'a'] == NULL) p->fii[y.y - 'a'] = new node(), cost--;
      p->fii[y.y - 'a']->c++;
      cost++;
      schema(p->fii[y.y - 'a'], y.x);
    }
}
void sterge(node *p) {
  for (int i = 0; i < 26; i++)
    if (p->fii[i] != NULL) sterge(p->fii[i]);
  delete p;
}
void hai(int x, node *p) {
  for (auto y : g[x])
    if (y.x != t[x]) {
      if (p->fii[y.y - 'a'] != NULL) {
        cost++;
        hai(y.x, p->fii[y.y - 'a']);
      }
    }
}
void dfs(int x) {
  s[x] = 1;
  fiuMare[x] = 0;
  for (auto y : g[x])
    if (y.x != t[x]) {
      h[y.x] = h[x] + 1;
      t[y.x] = x;
      dfs(y.x);
      s[x] += s[y.x];
      if (s[y.x] > s[fiuMare[x]]) fiuMare[x] = y.x;
    }
}
int main() {
  int n;
  fscanf(stdin, "%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    char ch;
    fscanf(stdin, "%d%d %c", &x, &y, &ch);
    g[x].push_back(myc(y, ch));
  }
  dfs(1);
  for (int i = 1; i <= n; i++)
    if (s[i] > 1) {
      root = new node();
      cost = 1;
      for (auto y : g[i])
        if ((y.x != t[i]) && (y.x != fiuMare[i])) schema(root, y.x), cost++;
      hai(fiuMare[i], root);
      sterge(root);
      ans[h[i] + 1] += cost;
    }
  int best = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] > ans[best]) best = i;
  fprintf(stdout, "%d\n%d\n", n - ans[best], best);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
