#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6;
const long long M = 2e6;
vector<long long> v[N];
long long tag[N], tr[N];
long long in[N], out[N];
long long col[N];
long long tim;
inline long long ls(long long p) { return p << 1; }
inline long long rs(long long p) { return p << 1 | 1; }
inline long long lowbit(long long x) { return x & -x; }
inline void pushdown(long long p) {
  if (tag[p]) {
    tr[ls(p)] = tag[p], tr[rs(p)] = tag[p];
    tag[ls(p)] = tag[p], tag[rs(p)] = tag[p];
    tag[p] = 0;
  }
}
inline void pushup(long long p) { tr[p] = tr[ls(p)] | tr[rs(p)]; }
void modify(long long l, long long r, long long x, long long y, long long z,
            long long p = 1) {
  if (x <= l && y >= r) {
    tr[p] = z;
    tag[p] = z;
    return;
  }
  pushdown(p);
  long long mid = l + r >> 1;
  if (x <= mid) modify(l, mid, x, y, z, ls(p));
  if (y > mid) modify(mid + 1, r, x, y, z, rs(p));
  pushup(p);
}
long long query(long long l, long long r, long long x, long long y,
                long long p = 1) {
  if (x <= l && y >= r) {
    return tr[p];
  }
  pushdown(p);
  long long res = 0;
  long long mid = l + r >> 1;
  if (x <= mid) res |= query(l, mid, x, y, ls(p));
  if (y > mid) res |= query(mid + 1, r, x, y, rs(p));
  return res;
}
void dfs(long long u, long long fa) {
  ++tim;
  in[u] = tim;
  for (auto it : v[u]) {
    if (it == fa) continue;
    dfs(it, u);
  }
  out[u] = tim;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> col[i];
  for (long long i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0);
  for (long long i = 1; i <= n; i++) modify(1, n, in[i], in[i], 1ll << col[i]);
  for (long long i = 1; i <= m; i++) {
    long long opt, x, y;
    cin >> opt;
    if (opt == 1) {
      long long x, y;
      cin >> x >> y;
      modify(1, n, in[x], out[x], 1ll << y);
    } else {
      long long x;
      cin >> x;
      long long k = query(1, n, in[x], out[x]);
      long long res = 0;
      while (k) {
        res++;
        k -= lowbit(k);
      }
      cout << res << endl;
    }
  }
}
