#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
const long long one = 1;
vector<int> adj[N];
int col[N], arrival[N], departure[N], timer = 0;
int nd[N];
struct node {
  long long val;
  int lazy;
  node *left, *right;
  node* build(int start, int end) {
    lazy = 0;
    if (start == end) {
      val = (one << col[nd[start]]);
    } else {
      int mid = (start + end) / 2;
      left = new node, right = new node, left = left->build(start, mid),
      right = right->build(mid + 1, end);
      val = left->val | right->val;
    }
    return this;
  }
  void lz(int start, int end) {
    if (lazy == 0) return;
    val = one << lazy;
    if (start != end) left->lazy = lazy, right->lazy = lazy;
    lazy = 0;
  }
  node* update(int start, int end, int a, int b, int v) {
    lz(start, end);
    int mid = (start + end) / 2;
    if (start >= a && end <= b) {
      lazy = v;
      lz(start, end);
    } else if (start > b || end < a)
      return this;
    else {
      left = left->update(start, mid, a, b, v);
      right = right->update(mid + 1, end, a, b, v);
      val = left->val | right->val;
    }
    return this;
  }
  long long query(int start, int end, int a, int b) {
    int mid = (start + end) / 2;
    lz(start, end);
    if (start >= a && end <= b)
      return val;
    else if (start > b || end < a)
      return 0;
    else
      return left->query(start, mid, a, b) | right->query(mid + 1, end, a, b);
  }
};
int cn(long long a) {
  int count = 0;
  while (a != 0) {
    count += a & 1;
    a >>= 1;
  }
  return count;
}
void dfs(int v, int p) {
  arrival[v] = ++timer;
  nd[arrival[v]] = v;
  for (auto c : adj[v]) {
    if (c != p) dfs(c, v);
  }
  departure[v] = timer;
}
int main() {
  int n, m, u, v, t, c;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", col + i);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v), adj[v].push_back(u);
  }
  dfs(1, 0);
  node* root = new node;
  root = root->build(1, n);
  while (m--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d %d", &v, &c);
      root = root->update(1, n, arrival[v], departure[v], c);
    } else {
      scanf("%d", &v);
      printf("%d\n", cn(root->query(1, n, arrival[v], departure[v])));
    }
  }
}
