#include <bits/stdc++.h>
const int N = 800005;
using namespace std;
long long ar[N], dp[4 * N], n, m, cur = 1, st[N], en[N], ors[4 * N];
vector<int> g[N];
void dfs(int u, int p) {
  st[u] = cur++;
  for (auto v : g[u]) {
    if (v != p) dfs(v, u);
  }
  en[u] = cur - 1;
}
void upd(int i, int l, int r, int se, int en, long long val) {
  if (se <= l && r <= en) {
    dp[i] = val;
    ors[i] = val;
    return;
  } else if (l > en || r < se) {
    return;
  } else {
    if (dp[i]) {
      dp[i * 2] = dp[i];
      dp[i * 2 + 1] = dp[i];
      ors[i * 2] = dp[i];
      ors[i * 2 + 1] = dp[i];
      dp[i] = 0;
    }
    int m = (l + r) / 2;
    upd(i * 2, l, m, se, en, val);
    upd(2 * i + 1, m + 1, r, se, en, val);
    ors[i] = ors[i * 2] | ors[i * 2 + 1];
  }
}
long long query(int i, int l, int r, int se, int en) {
  if (dp[i]) {
    dp[i * 2] = dp[i];
    dp[i * 2 + 1] = dp[i];
    ors[i * 2] = dp[i];
    ors[i * 2 + 1] = dp[i];
    dp[i] = 0;
  }
  if (se <= l && r <= en) {
    return ors[i];
  } else if (l > en || r < se) {
    return 0;
  }
  int m = (l + r) / 2;
  return query(i * 2, l, m, se, en) | query(i * 2 + 1, m + 1, r, se, en);
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1);
  long long one = 1;
  for (int i = 1; i <= n; i++) upd(1, 1, n, st[i], st[i], one << ar[i]);
  while (m--) {
    int op;
    cin >> op;
    if (op == 1) {
      int v, c;
      cin >> v >> c;
      upd(1, 1, n, st[v], en[v], one << c);
    } else {
      int v;
      cin >> v;
      cout << __builtin_popcountll(query(1, 1, n, st[v], en[v])) << '\n';
    }
  }
  return 0;
}
