#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " |       ";
  __f(comma + 1, args...);
}
void FastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(15);
}
long long modpow(long long a, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    p /= 2;
  }
  return ret % mod;
}
long long power(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a);
    a = (a * a);
    p /= 2;
  }
  return ret;
}
const int maxn = 8e5;
long long tree[4 * maxn];
long long lazy[4 * maxn];
int N;
inline void preupd(int node, int a, int b) {
  tree[node] = lazy[node];
  if (a != b) lazy[node * 2] = lazy[node * 2 + 1] = lazy[node];
  lazy[node] = 0;
}
inline void update(int i, int j, long long val, int node = 1, int a = 0,
                   int b = N - 1) {
  if (lazy[node] != 0) preupd(node, a, b);
  if (a > b || a > j || b < i) return;
  if (a >= i && b <= j) {
    tree[node] = val;
    if (a != b) lazy[node * 2] = lazy[node * 2 + 1] = val;
    return;
  }
  update(i, j, val, node * 2, a, (a + b) / 2);
  update(i, j, val, 1 + node * 2, 1 + (a + b) / 2, b);
  tree[node] = tree[node * 2] | tree[node * 2 + 1];
}
inline long long query(int i, int j, int node = 1, int a = 0, int b = N - 1) {
  if (a > b || a > j || b < i) return 0LL;
  if (lazy[node] != 0) preupd(node, a, b);
  if (a >= i && b <= j) return tree[node];
  long long q1 = query(i, j, node * 2, a, (a + b) / 2);
  long long q2 = query(i, j, 1 + node * 2, 1 + (a + b) / 2, b);
  return q1 | q2;
}
vector<int> g[400010];
int col[400010], insert[400010], out[400010];
bool vis[400010];
int tim = 0;
void dfs(int x) {
  vis[x] = 1;
  insert[x] = tim++;
  for (int i = 0; i < (int)(g[x].size()); i++)
    if (!vis[g[x][i]]) dfs(g[x][i]);
  out[x] = tim++;
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  N = 2 * n;
  for (int i = 0; i < n; i++) scanf("%d", &col[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    g[x - 1].push_back(y - 1);
    g[y - 1].push_back(x - 1);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    update(insert[i], insert[i], 1LL << col[i]);
    update(out[i], out[i], 1LL << col[i]);
  }
  for (int i = 0; i < m; i++) {
    int typ, v, c;
    scanf("%d", &typ);
    if (typ == 1) {
      scanf("%d%d", &v, &c);
      update(insert[v - 1], out[v - 1], 1LL << c);
    } else {
      scanf("%d", &v);
      printf("%d\n", __builtin_popcountll(query(insert[v - 1], out[v - 1])));
    }
  }
  return 0;
}
