#include <bits/stdc++.h>
using namespace std;
const int MN = 3e5 + 44, A = 26;
vector<pair<int, char> > graf[MN];
const unsigned long long empty = 0;
unsigned long long keys[MN][A];
unsigned long long key(int i, char x) {
  int a = x - 'a';
  while (!keys[i][a]) {
    keys[i][a] =
        (unsigned long long)rand() | ((unsigned long long)rand() << 16) |
        ((unsigned long long)rand() << 32) | ((unsigned long long)rand() << 48);
  }
  return keys[i][a];
}
unsigned long long hash_up[MN];
int diff[MN];
set<unsigned long long> under[MN];
int size[MN];
int level[MN];
int ans[MN];
pair<int, int> dfs1(int x, int y = -1, int d = 0,
                    unsigned long long up_hash = 0) {
  level[d]++;
  int dunder = 1, second = 1;
  for (auto v : graf[x])
    if (v.first != y) {
      pair<int, int> u = dfs1(v.first, x, d + 1, up_hash ^ key(d, v.second));
      dunder = max(dunder, u.first);
      second += u.second;
    }
  hash_up[x] = up_hash;
  size[x] = second;
  return make_pair(dunder + 1, second);
}
void dfs2(int x, int y = -1, int d = 0) {
  int M = 0, wh = 0;
  char letter;
  for (auto v : graf[x]) {
    if (v.first != y) {
      dfs2(v.first, x, d + 1);
      if (size[v.first] > M) {
        M = size[v.first];
        wh = v.first;
        letter = v.second;
      }
    }
  }
  if (M > 0) {
    swap(under[x], under[wh]);
    set<unsigned long long> other;
    for (auto v : graf[x])
      if (v.first != y && v.first != wh) {
        for (auto h : under[v.first]) {
          other.insert(h ^ key(d, v.second) ^ key(d, letter));
        }
      }
    ans[d + 1] += under[x].size() - 1;
    for (auto o : other) {
      if (under[x].find(o) == under[x].end()) {
        ans[d + 1]++;
      }
    }
    for (auto v : graf[x]) {
      if (v.first != y && v.first != wh) {
        for (auto h : under[v.first]) under[x].insert(h);
      }
    }
  }
  under[x].insert(hash_up[x]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    char c[2];
    scanf("%d%d%1s", &a, &b, c);
    graf[a].emplace_back(b, c[0]);
    graf[b].emplace_back(a, c[0]);
  }
  dfs1(1);
  for (int i = 1; i < n; ++i) ans[i] = ans[i - 1] + level[i - 1];
  dfs2(1);
  int opt = n, count = 0;
  for (int i = 1; i < n; ++i) {
    if (opt > ans[i]) {
      opt = ans[i];
      count = i;
    }
  }
  printf("%d\n%d\n", opt, count);
}
