#include <bits/stdc++.h>
using namespace std;
int __builtin_pop_count(long long int val) {
  int res = 0;
  while (val) {
    if ((val & 1LL)) {
      res++;
    }
    val >>= 1LL;
  }
  return res;
}
int n;
int m;
long long int lazy[400002 * 4];
long long int seg[400002 * 4];
long long int cc[400002];
long long int c[400002];
inline void init(int b, int l, int r) {
  if (l + 1 == r) {
    seg[b] = (1LL << c[l]);
    return;
  }
  init(b * 2 + 1, l, (l + r) >> 1);
  init(b * 2 + 2, (l + r) >> 1, r);
  seg[b] = (seg[b * 2 + 1] | seg[b * 2 + 2]);
}
void update(int b) {
  if (lazy[b] != -1) {
    seg[b] = (1LL << lazy[b]);
    if (b * 2 + 2 < 400002 * 4) {
      lazy[b * 2 + 1] = lazy[b * 2 + 2] = lazy[b];
    }
  }
  lazy[b] = -1;
}
inline void add(int b, int l, int r, int ll, int rr, int x) {
  update(b);
  if (r <= ll || rr <= l) return;
  if (ll <= l && r <= rr) {
    lazy[b] = x;
    update(b);
    return;
  }
  add(b * 2 + 1, l, (l + r) >> 1, ll, rr, x);
  add(b * 2 + 2, (l + r) >> 1, r, ll, rr, x);
  seg[b] = (seg[b * 2 + 1] | seg[b * 2 + 2]);
}
inline long long int query(int b, int l, int r, int ll, int rr) {
  update(b);
  if (r <= ll || rr <= l) {
    return 0;
  }
  if (ll <= l && r <= rr) {
    return seg[b];
  }
  return query(b * 2 + 1, l, (l + r) >> 1, ll, rr) |
         query(b * 2 + 2, (l + r) >> 1, r, ll, rr);
}
int ord[400002];
int en[400002];
vector<int> v[400002];
inline void dfs(int b, int pr, int &o) {
  ord[b] = o;
  o++;
  for (int i = 0; i < v[b].size(); i++) {
    int go = v[b][i];
    if (go == pr) continue;
    dfs(go, b, o);
  }
  en[b] = o;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &cc[i]);
    cc[i]--;
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(lazy, -1, sizeof(lazy));
  int o = 0;
  dfs(0, -1, o);
  for (int i = 0; i < n; i++) {
    c[ord[i]] = cc[i];
  }
  init(0, 0, n);
  while (m--) {
    int ty;
    scanf("%d", &ty);
    int v;
    scanf("%d", &v);
    v--;
    if (ty == 1) {
      int C;
      scanf("%d", &C);
      C--;
      add(0, 0, n, ord[v], en[v], C);
    } else {
      printf("%d\n", __builtin_pop_count(query(0, 0, n, ord[v], en[v])));
    }
  }
  return 0;
}
