#include <stdio.h>
#include <iostream>
#include <vector>
#define N 400009
#define M 800099
using namespace std;
int start[N] ;
int en [N] ;
int color[N] ;
int E[M] ;
int pos = 0 ;
vector <int> tree[N] ;
long long int ST[4*M] ;
int lazy[4*M] ;
void update(int i, int j, int low, int high, int pos, int value){
if (lazy[pos]){
if (pos % 2)
ST[pos] = ST[pos / 2] ;
else
ST[pos] = ST[(pos / 2) - 1] ;
if (low != high){
lazy[2*pos+1]++ ;
lazy[2*pos+2]++ ;
}
lazy[pos] = 0 ;
}
if (i > high || j < low)
return ;
if (i <= low && high <= j){
ST[pos] = 1LL << value ;
lazy[2*pos+1]++ ;
lazy[2*pos+2]++ ;
return ;
}
int mid = ((low+high) / 2) ;
update(i, j, low, mid, 2*pos+1, value) ;
update(i, j, mid+1, high, 2*pos+2, value) ;
ST[pos] = ST[2*pos+1] | ST[2*pos+2] ;
}
long long int query(int i, int j, int low, int high, int pos){
if(lazy[pos]){
if (pos % 2)
ST[pos] = ST[pos / 2] ;
else
ST[pos] = ST[(pos / 2) - 1] ;
if (low != high){
lazy[2*pos+1]++ ;
lazy[2*pos+2]++ ;
}
lazy[pos] = 0 ;
}
if (i > high || j < low)
return 0 ;
if (i <= low && high <= j)
return ST[pos] ;
int mid = (low+high) / 2 ;
return (query(i, j, low, mid, 2*pos+1) | query(i, j, mid+1, high, 2*pos+2)) ;
}
void ETT(int v, int pv){
E[pos] = v ;
if (!start[v])
start[v] = pos ;
pos++ ;
for (int i = 0; i < tree[v].size(); i++){
int u = tree[v][i] ;
if (u == pv)
continue ;
ETT(u, v) ;
E[pos] = v ;
pos ++ ;
}
if (!en[v])
en[v] = pos-1 ;
}
int main(){
int n, m, x, y, L, R, count, value ;
long long int ans ;
cin >> n >> m ;
for (int i = 1; i <= n; i++)
cin >> color[i] ;
for (int i = 0; i < n-1; i++){
cin >> x >> y ;
tree[x].push_back(y) ;
tree[y].push_back(x) ;
}
ETT(1, 0) ;
/*for (int i = 0; i < 2*n-1; i++)
cout << E[i] << " " ;
cout << endl ;
for (int i = 0; i <= n; i++)
cout << start[i] << " ";
cout << endl ;
for (int i = 0; i <= n; i++)
cout << en[i] << " " ;
cout << endl;*/
for(int i = 1; i <=n ; i++)
update(start[i], en[i], 0, 2*n-2, 0, color[i]) ;
/*cout << endl ;
for (int i = 0; i < 90; i++)
cout << ST[i] << " " ;
cout << endl;*/
for (int i = 0; i < m; i++){
cin >> x >> y ;
L = start[y] ;
R = en[y] ;
//cout << x << " " << y << endl ;
//cout << L << " " << R << endl ;
if (x == 2){
ans = query(L, R, 0, 2*n-2, 0) ;
cout << __builtin_popcount(ans) << endl;
}
else{
cin >> value ;
update(L, R, 0, 2*n-2, 0, value) ;
/*cout << "here" << endl;
for (int i = 0; i < 40; i++)
cout << ST[i] << " " ;
cout << endl ;*/
}
}
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KCiNkZWZpbmUgTiA0MDAwMDkKI2RlZmluZSBNIDgwMDA5OQoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBzdGFydFtOXQk7CmludCBlbiAgW05dCTsKaW50IGNvbG9yW05dCTsKaW50IEVbTV0JCTsKaW50IHBvcyA9IDAJCTsKCnZlY3RvciA8aW50PiB0cmVlW05dCTsKbG9uZyBsb25nIGludCBTVFs0Kk1dCTsKaW50IGxhenlbNCpNXQk7Cgp2b2lkIHVwZGF0ZShpbnQgaSwgaW50IGosIGludCBsb3csIGludCBoaWdoLCBpbnQgcG9zLCBpbnQgdmFsdWUpewoKCWlmIChsYXp5W3Bvc10pewoKCQlpZiAocG9zICUgMikKCQkJU1RbcG9zXSA9IFNUW3BvcyAvIDJdCTsKCQllbHNlCgkJCVNUW3Bvc10gPSBTVFsocG9zIC8gMikgLSAxXQk7CgoJCWlmIChsb3cgIT0gaGlnaCl7CgkJCWxhenlbMipwb3MrMV0rKwk7CgkJCWxhenlbMipwb3MrMl0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