#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10, mod = 1e9 + 7;
int n, m, c[N];
vector<int> g[N];
long long tree[4 * N], inka[4 * N];
int timer = -1, in[N], out[N], at[N];
void dfs(int u, int p = -1) {
  in[u] = ++timer;
  at[timer] = c[u] - 1;
  for (int x : g[u])
    if (x - p) {
      dfs(x, u);
    }
  out[u] = timer;
}
inline void update(int p) { tree[p] = (tree[p << 1] | tree[(p << 1) ^ 1]); }
inline void push(int p) {
  if (inka[p]) {
    tree[p << 1] = inka[p << 1] = inka[p];
    tree[(p << 1) ^ 1] = inka[(p << 1) ^ 1] = inka[p];
    inka[p] = 0;
  }
}
void build(int p, int l, int r) {
  if (l == r) {
    int c = at[l];
    tree[p] = (1ll << c);
    return;
  }
  int mid = (r + l) >> 1, left = p << 1;
  build(left, l, mid);
  build(left + 1, mid + 1, r);
  update(p);
}
void range_inc(int p, int l, int r, int ul, int ur, int v) {
  if (ul <= l && ur >= r) {
    tree[p] = (1ll << v);
    inka[p] = (1ll << v);
    return;
  }
  if (ul > r || ur < l) return;
  int mid = (l + r) >> 1, left = p << 1;
  push(p);
  range_inc(left, l, mid, ul, ur, v);
  range_inc(left + 1, mid + 1, r, ul, ur, v);
  update(p);
}
long long query(int p, int l, int r, int ql, int qr) {
  if (ql <= l && qr >= r) {
    return (tree[p]);
  }
  if (ql > r || qr < l) return 0;
  push(p);
  update(p);
  int mid = (l + r) >> 1, left = p << 1;
  long long ret =
      (query(left, l, mid, ql, qr) | query(left + 1, mid + 1, r, ql, qr));
  return ret;
}
void reset() {
  for (int i = 0; i < 4 * N; ++i) tree[i] = inka[i] = 0;
}
int main() {
  reset();
  cin >> n >> m;
  for (int i = 0; i < n; ++i) scanf("%d", c + i);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  build(1, 0, timer);
  while (m--) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      int u, c;
      scanf("%d %d", &u, &c);
      --u;
      --c;
      range_inc(1, 0, timer, in[u], out[u], c);
    } else {
      int u;
      scanf("%d", &u);
      --u;
      long long x = query(1, 0, timer, in[u], out[u]);
      printf("%d\n", __builtin_popcountll(x));
    }
  }
}
