#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
vector<pair<int, int> > mp[20105];
int d[20105], fa[20105], dfn[20105], cnt;
int pc[20105], len[20105], sig[20105];
void dfsinit(int x, int pa) {
  d[x] = d[pa] + 1;
  fa[x] = pa;
  dfn[++cnt] = x;
  for (auto child : mp[x])
    if (child.first != pa) {
      int num = child.second;
      pc[child.first] = num;
      dfsinit(child.first, x);
    }
}
vector<int> ss, st;
int N;
int dfs(int x, int pa, int len, bool sm) {
  int ans = 1;
  for (auto ch : mp[x])
    if (ch.first != pa) {
      if (!sm && len == N) continue;
      if (!sm && len == N - 1 && ch.second == ss[len]) continue;
      if (sm)
        ans += dfs(ch.first, x, len + 1, 1);
      else if (ch.second <= ss[len]) {
        assert(len < N);
        ans += dfs(ch.first, x, len + 1, ch.second < ss[len]);
      }
    }
  return ans;
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n - 1); (i)++) {
    int u, v;
    char ope[2];
    scanf("%d%d%s", &u, &v, ope);
    int c = ope[0] - 'a';
    mp[u].push_back({v, c});
    mp[v].push_back({u, c});
  }
  dfsinit(1, 0);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ss.clear();
    st.clear();
    for (int u = x, v = y; u != v;) {
      if (d[u] < d[v]) {
        st.push_back(pc[v]);
        v = fa[v];
      } else {
        ss.push_back(pc[u]);
        u = fa[u];
      }
    }
    while (!st.empty()) {
      ss.push_back(st.back());
      st.pop_back();
    }
    N = ss.size();
    int u = x;
    memset(len, 255, sizeof len);
    len[u] = 0;
    sig[u] = 1;
    for (int p = u; fa[p]; p = fa[p]) {
      len[fa[p]] = len[p] + 1;
      if (sig[p] == 1) {
        if (len[fa[p]] > N || pc[p] > ss[len[fa[p]] - 1])
          sig[fa[p]] = 2;
        else
          sig[fa[p]] = (pc[p] == ss[len[fa[p]] - 1]);
      } else
        sig[fa[p]] = sig[p];
    }
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      int p = dfn[j];
      if (len[p] == -1) {
        len[p] = len[fa[p]] + 1;
        sig[p] = sig[fa[p]];
        if (sig[p] == 1) {
          if (len[p] > N || pc[p] > ss[len[p] - 1])
            sig[p] = 2;
          else
            sig[p] = (pc[p] == ss[len[p] - 1]);
        }
      }
      if (!sig[p] || (sig[p] == 1 && len[p] < N)) ++ans;
    }
    printf("%d\n", ans - 1);
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
