#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
const long long inf = 1e9 + 7;
long long n, m;
bitset<61> bt[maxn << 2], tmp;
int lz[maxn << 2], a[maxn];
vector<int> g[maxn];
int in[maxn], out[maxn], rk[maxn];
int tot = 0, root = 1;
inline void dfs(int x, int fa) {
  in[x] = ++tot;
  rk[tot] = x;
  int len = g[x].size();
  for (int i = 0; i < len; i++) {
    int to = g[x][i];
    if (to == fa) continue;
    dfs(to, x);
  }
  out[x] = tot;
  return;
}
inline void pushUp(int x) { bt[x] = bt[x << 1] | bt[x << 1 | 1]; }
inline void pushDown(int x) {
  if (lz[x]) {
    bt[x << 1].reset();
    bt[x << 1].set(lz[x]);
    bt[x << 1 | 1].reset();
    bt[x << 1 | 1].set(lz[x]);
    lz[x << 1] = lz[x << 1 | 1] = lz[x];
    lz[x] = 0;
  }
  return;
}
inline void build(int l, int r, int x) {
  if (l == r) {
    bt[x].set(a[rk[l]]);
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, x << 1);
  build(mid + 1, r, x << 1 | 1);
  pushUp(x);
  return;
}
inline void upd(int l, int r, int x, int L, int R, int v) {
  if (L <= l && R >= r) {
    bt[x].reset();
    bt[x].set(v);
    lz[x] = v;
    return;
  }
  pushDown(x);
  int mid = (l + r) >> 1;
  if (mid >= L) upd(l, mid, x << 1, L, R, v);
  if (mid < R) upd(mid + 1, r, x << 1 | 1, L, R, v);
  pushUp(x);
  return;
}
inline void query(int l, int r, int x, int L, int R) {
  if (L <= l && R >= r) {
    tmp |= bt[x];
    return;
  }
  pushDown(x);
  int mid = (l + r) >> 1;
  if (mid >= L) query(l, mid, x << 1, L, R);
  if (mid < R) query(mid + 1, r, x << 1 | 1, L, R);
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(root, root);
  build(1, n, 1);
  while (m--) {
    int op, x, y;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d", &x, &y);
      upd(1, n, 1, in[x], out[x], y);
    } else {
      tmp.reset();
      scanf("%d", &y);
      query(1, n, 1, in[y], out[y]);
      printf("%d\n", tmp.count());
    }
  }
  return 0;
}
