#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 10, MAX = 4e5 + 1e4, MOD = 1e9 + 7, MAXL = 25;
void OUT(long double o, int x) {
  cout << fixed << setprecision(x) << o;
  return;
}
long long seg[4 * MAX], c[MAX], t = 0, st[MAX], fi[MAX], lazy[4 * MAX];
vector<int> adj[MAX];
void dfs(long long v, long long p) {
  t++;
  st[v] = t;
  for (long long u : adj[v])
    if (u != p) dfs(u, v);
  fi[v] = t;
}
void shift(int id) {
  if (lazy[id] == 0) return;
  seg[id * 2] = lazy[id];
  lazy[id * 2] = lazy[id];
  seg[id * 2 + 1] = lazy[id];
  lazy[id * 2 + 1] = lazy[id];
  lazy[id] = 0;
  return;
}
void upd(int id, int b, int e, int l, int r, long long x) {
  if (r <= b || e <= l) return;
  if (l <= b && e <= r) {
    lazy[id] = x;
    seg[id] = x;
    return;
  }
  int m = (b + e) / 2;
  shift(id);
  upd(id * 2, b, m, l, r, x);
  upd(id * 2 + 1, m, e, l, r, x);
  seg[id] = seg[id * 2] | seg[id * 2 + 1];
  return;
}
long long geta(int id, int b, int e, int l, int r) {
  if (e <= l || r <= b) return 0;
  if (l <= b && e <= r) return seg[id];
  shift(id);
  int m = (b + e) / 2;
  return geta(id * 2, b, m, l, r) | geta(id * 2 + 1, m, e, l, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    upd(1, 1, n + 1, st[i], st[i] + 1, 1ll << (c[i] - 1));
  while (m--) {
    long long x, y;
    cin >> x;
    if (x == 1) {
      cin >> x >> y;
      upd(1, 1, n + 1, st[x], fi[x] + 1, 1ll << (y - 1));
    } else {
      cin >> x;
      cout << __builtin_popcountll(geta(1, 1, n + 1, st[x], fi[x] + 1)) << "\n";
    }
  }
  return 0;
}
