#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL mod = 1000000000000000003, base = 163;
template <LL mod = 1000000007>
struct modint {
  LL x;
  modint(LL y = 0) : x((y % mod + mod) % mod) {}
  friend modint operator^(modint a, int64_t b) {
    modint r = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) r *= a;
    return r;
  }
  friend modint operator-(modint a) { return modint(0) - a; }
  friend modint operator!(modint a) { return a ^ (mod - 2); }
  modint& operator/=(modint const& b) { return *this *= !b; }
  friend modint operator+(modint a, modint const& b) { return a += b; }
  friend modint operator-(modint a, modint const& b) { return a -= b; }
  friend modint operator*(modint a, modint const& b) { return a *= b; }
  friend modint operator/(modint a, modint const& b) { return a /= b; }
  friend bool operator!=(const modint& a, const modint b) { return a.x != b.x; }
  friend bool operator==(const modint& a, const modint b) { return a.x == b.x; }
  modint& operator*=(modint const& b) {
    x = (__int128_t)x * (__int128_t)b.x % mod;
    return *this;
  }
  friend ostream& operator<<(ostream& os, modint const& a) { return os << a.x; }
  modint& operator+=(modint const& b) {
    x += b.x;
    x = (x >= mod) ? x - mod : x;
    return *this;
  }
  modint& operator-=(modint const& b) {
    x = x >= b.x ? x - b.x : x - b.x + mod;
    return *this;
  }
};
using mint = modint<mod>;
namespace C {
vector<mint> P;
void init(int n, int base = 2) {
  P = vector<mint>(n + 1, 1);
  for (int i = 1; i <= n; i++) P[i] = P[i - 1] * base;
}
}  // namespace C
using namespace C;
const int N = 3e5 + 10;
vector<pair<int, int>> adj[N];
map<LL, int> mp[N];
int ans[N], cnt[N];
void dfs(int v, mint hsh = 0, int lvl = 0) {
  int y = 0;
  for (auto& [u, x] : adj[v]) {
    dfs(u, hsh + x * P[lvl], lvl + 1);
    if (mp[u].size() > mp[v].size()) {
      swap(mp[u], mp[v]);
      swap(x, y);
    }
  }
  cnt[lvl]++;
  map<LL, int> mp1;
  mp[v][hsh.x] = 1;
  for (auto [u, x] : adj[v]) {
    for (auto [h1, z] : mp[u]) {
      mint h = h1;
      h += P[lvl] * (y - x);
      if (!mp[v].count(h.x)) mp1[h.x] = 1;
    }
  }
  ans[lvl] += (int)mp[v].size() + (int)mp1.size() - (bool)adj[v].size();
  for (auto [u, x] : adj[v]) {
    for (auto [h, y] : mp[u]) {
      mp[v][h] = 1;
    }
  }
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  init(n, 157);
  for (int i = 1; i < n; i++) {
    char ch;
    int u, v;
    cin >> u >> v >> ch;
    adj[u].push_back(make_pair(v, (int)ch));
  }
  int res = n, sum = 0, pos = 0;
  dfs(1);
  for (int i = 0; i <= n; i++) {
    if (res > sum + ans[i]) {
      pos = i + 1;
      res = sum + ans[i];
    }
    sum += cnt[i];
  }
  cout << res << endl << pos << endl;
}
