#include #include #include #define Nmax 100010 using namespace std; int n , m , i , x , y , OP , ap[30] , sol[Nmax] , final , nr , crt; vector < int > g[Nmax]; char c , tip[Nmax]; bool sel[Nmax] , ok; void dfs(int x) { int i; sel[x] = true; ap[tip[x]-'a']++; if (x == final) ok = true; for (i = 0; i < g[x].size() && !ok; ++i) if (!sel[g[x][i]]) { dfs(g[x][i]); if (!ok) ap[tip[g[x][i]] - 'a']--; } } int main() { //freopen("tree.in","r",stdin); //freopen("tree.out","w",stdout); scanf("%d %d\n", &n , &m); for (i = 1; i <= n; ++i) scanf("%c", &tip[i]); scanf("\n"); for (i = 1; i < n ; ++i) { scanf("%d %d", &x , &y); g[x].push_back(y); g[y].push_back(x); } nr = n; for (i = 1; i <= m; ++i) { scanf("%d", &OP); if (OP == 1) { crt = 0; for (int j = 'a' - 'a'; j <= 'z' - 'a'; ++j) ap[j] = 0; for (int j = 1; j <= nr; ++j) sel[j] = false; scanf("%d %d\n", &x , &final); ok = false; dfs(x); for (int j = 'a' - 'a'; j <= 'z' - 'a'; ++j) if (ap[j] % 2 == 1) ++crt; sol[++sol[0]] = crt; } else { scanf("%d %c\n", &x , &c); g[x].push_back(++nr); g[nr].push_back(x); tip[nr] = c; } } for (i = 1; i <= sol[0]; ++i) printf("%d\n", sol[i]); return 0; }