#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 4e5 + 123;
const long long inf = 1e9 + 123;
const long long linf = 1e18 + 123;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double pi = acos(-1);
int dx[8] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[8] = {1, 0, 0, -1, 1, 1, -1, -1};
int n, m, c[maxn], timer = 0, tin[maxn], tout[maxn];
long long t[maxn * 4], add[maxn * 4];
vector<long long> g[maxn];
void dfs(int v, int pr) {
  timer++;
  tin[v] = timer;
  for (int to : g[v]) {
    if (to == pr) {
      continue;
    }
    dfs(to, v);
  }
  tout[v] = timer;
}
void push(int v, int tl, int tr) {
  if (add[v]) {
    t[v] = add[v];
    if (tl != tr) {
      add[v + v] = add[v];
      add[v + v + 1] = add[v];
    }
    add[v] = 0;
  }
}
void update(int v, int tl, int tr, int l, int r, long long val) {
  push(v, tl, tr);
  if (l > tr || tl > r) {
    return;
  }
  if (l <= tl && tr <= r) {
    add[v] = (1ll << val);
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  update(v + v, tl, tm, l, r, val);
  update(v + v + 1, tm + 1, tr, l, r, val);
  t[v] = (t[v + v] | t[v + v + 1]);
}
long long get(int v, int tl, int tr, int l, int r) {
  push(v, tl, tr);
  if (tl > r || l > tr) {
    return 0;
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  return (get(v + v, tl, tm, l, r) | get(v + v + 1, tm + 1, tr, l, r));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1, x, y; i < n; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, -1);
  for (int i = 1; i <= n; i++) {
    update(1, 1, n, tin[i], tin[i], c[i]);
  }
  while (m--) {
    int type, v;
    cin >> type >> v;
    if (type == 1) {
      long long color;
      cin >> color;
      update(1, 1, n, tin[v], tout[v], color);
    } else {
      long long cur = get(1, 1, n, tin[v], tout[v]);
      int cntr = 0;
      for (int i = 0; i <= 60; i++) {
        if (cur & (1ll << i)) {
          cntr++;
        }
      }
      cout << cntr << "\n";
    }
  }
  exit(0);
}
