#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int MAXN = 4e5 + 2;
vector<int> v[MAXN];
long long tree[4 * MAXN], lazy[4 * MAXN];
int arr[MAXN], in[MAXN], out[MAXN], tim = 0, col[MAXN];
void dfs(int node, int par) {
  arr[tim] = node;
  in[node] = tim;
  for (int x : v[node]) {
    if (x == par) continue;
    tim++;
    dfs(x, node);
  }
  out[node] = tim;
}
void build(int node, int st, int end) {
  if (st == end) {
    tree[node] = 1ll << (col[arr[st]]);
    return;
  }
  int mid = (st + end) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, end);
  tree[node] = tree[2 * node] | tree[2 * node + 1];
}
long long query(int node, int st, int end, int l, int r) {
  if (lazy[node]) {
    tree[node] = (1ll << lazy[node]);
    if (st != end) {
      lazy[2 * node] = lazy[node];
      lazy[2 * node + 1] = lazy[node];
    }
    lazy[node] = 0;
  }
  if (st >= l && end <= r) return tree[node];
  if (st > r || end < l) return 0;
  int mid = (st + end) / 2;
  return (query(2 * node, st, mid, l, r) |
          query(2 * node + 1, mid + 1, end, l, r));
}
void update(int node, int st, int end, int l, int r, int coli) {
  if (lazy[node]) {
    tree[node] = (1ll << lazy[node]);
    if (st != end) {
      lazy[2 * node] = lazy[node];
      lazy[2 * node + 1] = lazy[node];
    }
    lazy[node] = 0;
  }
  if (st > r || end < l) return;
  if (st >= l && end <= r) {
    tree[node] = (1ll << coli);
    if (st != end) {
      lazy[2 * node] = coli;
      lazy[2 * node + 1] = coli;
    }
    return;
  }
  int mid = (st + end) / 2;
  update(2 * node, st, mid, l, r, coli);
  update(2 * node + 1, mid + 1, end, l, r, coli);
  tree[node] = tree[2 * node] | tree[2 * node + 1];
}
int main() {
  int n, q;
  scanf("%d", &n);
  scanf("%d", &q);
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", &col[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 1);
  build(1, 0, tim);
  while (q--) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int node, color;
      scanf("%d", &node);
      scanf("%d", &color);
      update(1, 0, tim, in[node], out[node], color);
    } else {
      int node;
      scanf("%d", &node);
      long long ans = query(1, 0, tim, in[node], out[node]);
      ans = __builtin_popcountll(ans);
      printf("%lld\n", ans);
    }
  }
  return 0;
}
