#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int n;
long long int t[2 * N];
int h;
long long int d[N];
void calc(int p, int k) {
  if (d[p] == 0)
    t[p] = t[p << 1] | t[p << 1 | 1];
  else
    t[p] = d[p];
}
void apply(int p, long long int value, int k) {
  t[p] = value;
  if (p < n) d[p] = value;
}
void build(int l, int r) {
  int k = 2;
  for (l += n, r += n - 1; l > 1; k <<= 1) {
    l >>= 1, r >>= 1;
    for (int i = r; i >= l; --i) calc(i, k);
  }
}
void push(int l, int r) {
  int s = h, k = 1 << (h - 1);
  for (l += n, r += n - 1; s > 0; --s, k >>= 1)
    for (int i = l >> s; i <= r >> s; ++i)
      if (d[i] != 0) {
        apply(i << 1, d[i], k);
        apply(i << 1 | 1, d[i], k);
        d[i] = 0;
      }
}
void inc(int l, int r, long long int value) {
  if (value == 0) return;
  push(l, l + 1);
  push(r - 1, r);
  int l0 = l, r0 = r, k = 1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
    if (l & 1) apply(l++, value, k);
    if (r & 1) apply(--r, value, k);
  }
  build(l0, l0 + 1);
  build(r0 - 1, r0);
}
long long int query(int l, int r) {
  push(l, l + 1);
  push(r - 1, r);
  long long int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res |= t[l++];
    if (r & 1) res |= t[--r];
  }
  return res;
}
vector<vector<int> > adj;
vector<int> col, start, fin;
vector<long long int> arr;
void f(int i, int p) {
  start[i] = arr.size();
  arr.push_back(1LL << col[i]);
  for (int j : adj[i])
    if (j != p) f(j, i);
  fin[i] = arr.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  memset(t, 0, 2 * N * 4);
  memset(d, 0, N * 4);
  int m;
  cin >> n >> m;
  h = sizeof(int) * 8 - __builtin_clz(n);
  col = start = fin = vector<int>(n, 0);
  adj = vector<vector<int> >(n);
  for (int((i)) = (0); ((i)) < ((n)); ((i))++) cin >> col[i];
  for (int((i)) = (0); ((i)) < ((n - 1)); ((i))++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  f(0, -1);
  for (int((i)) = (0); ((i)) < ((n)); ((i))++) {
    inc(i, i + 1, arr[i]);
  }
  for (int((i)) = (0); ((i)) < ((m)); ((i))++) {
    int q;
    cin >> q;
    if (q == 2) {
      int v;
      cin >> v;
      v--;
      long long int res = query(start[v], fin[v]);
      int ans = 0;
      for (int(j) = (1); (j) < (62); (j)++)
        if (res & (1LL << j)) ans++;
      cout << ans << endl;
    } else {
      int v, c;
      cin >> v >> c;
      v--;
      inc(start[v], fin[v], 1LL << c);
    }
  }
}
