#include <bits/stdc++.h>
using namespace std;
vector<long long int> p[400005], sz(400005), f(4000005, 0), a(4000005),
    b(4000005), lazy(4000005);
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int bpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res % 1000000007;
}
void fact(long long int i) {
  f[0] = 1;
  for (long long int k = 1; k <= i; k++) {
    (f[k] = f[k - 1] * k) %= 1000000007;
  }
}
long long int isprime(long long int n) {
  if (n == 1) return 0;
  for (long long int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return 0;
  return 1;
}
long long int find(long long int x) {
  if (f[x] == x)
    return x;
  else
    return f[x] = find(f[x]);
}
bool cmp(long long int x, long long int y) { return x < y; }
long long int comb(long long int i, long long int j) {
  long long int k = f[i];
  long long int g = (f[j] * (f[i - j])) % 1000000007;
  long long int h = bpow(g, 1000000007 - 2);
  return (k * h) % 1000000007;
}
long long int c = 0;
void push(long long int i) {
  if (lazy[i]) {
    f[2 * i] = f[2 * i + 1] = lazy[2 * i] = lazy[2 * i + 1] = lazy[i];
    lazy[i] = 0;
  }
}
void dfs(long long int i, long long int pr) {
  c++;
  b[i] = c;
  sz[i]++;
  for (auto u : p[i]) {
    if (u != pr) {
      dfs(u, i);
      sz[i] += sz[u];
    }
  }
}
void update(long long int i, long long int tl, long long int tr,
            long long int l, long long int r, long long int x) {
  if (tl > r or tr < l) return;
  if (l <= tl && tr <= r) {
    f[i] = lazy[i] = x;
    return;
  }
  push(i);
  long long int tm = (tl + tr) / 2;
  update(2 * i, tl, tm, l, min(tm, r), x);
  update(2 * i + 1, tm + 1, tr, max(tm + 1, l), r, x);
  f[i] = (f[2 * i] | f[2 * i + 1]);
}
long long int query(long long int i, long long int tl, long long int tr,
                    long long int l, long long int r) {
  if (tl > r or tr < l) return 0;
  if (l <= tl && tr <= r) {
    return f[i];
  }
  push(i);
  long long int ans = 0, tm = (tl + tr) / 2;
  ans |= query(2 * i, tl, tm, l, min(r, tm));
  ans |= query(2 * i + 1, tm + 1, tr, max(tm + 1, l), r);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long int x, y;
  for (long long int i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    p[x].push_back(y);
    p[y].push_back(x);
  }
  dfs(1, 0);
  for (long long int i = 1; i <= n; i++) {
    update(1, 1, n, b[i], b[i], (1ll << a[i]));
  }
  long long int g, h, k;
  while (m--) {
    cin >> g;
    if (g == 1) {
      cin >> h >> k;
      update(1, 1, n, b[h], b[h] + sz[h] - 1, (1ll << k));
    } else {
      cin >> h;
      long long int ans = query(1, 1, n, b[h], b[h] + sz[h] - 1);
      long long int cnt = 0;
      while (ans > 0) {
        if (ans & 1) cnt++;
        ans >>= 1;
      }
      cout << cnt << "\n";
    }
  }
}
