#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
const long long MaxN = 1e5 + 100;
const long long mod = 1e9 + 7;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
inline long long fast_expo(long long base, long long power,
                           long long modulo = mod) {
  long long x = base, cnt = power, ans = 1;
  while (cnt) {
    if (cnt & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    cnt >>= 1;
  }
  long long tmp = ans;
  return tmp;
}
inline long long fib(long long n, long long a = 1, long long b = 1,
                     long long c = 1, long long d = 0, long long acca = 0,
                     long long accb = 1, long long m = mod) {
  if (n == 0) return acca;
  if (n & 1)
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m,
               ((a * acca) % m + (b * accb) % m) % m,
               ((c * acca) % m + (d * accb) % m) % m, m);
  else
    return fib(n / 2, ((a * a) % m + (b * c) % m) % m,
               ((a * b) % m + (b * d) % m) % m, (c * (a + d) % m) % m,
               ((c * b) % m + (d * d) % m) % m, acca, accb, m);
}
struct base {
  double x, y;
  base() {
    x = 0;
    y = 0;
  }
  base(double a) {
    x = a;
    y = 0;
  }
  base(double a, double b) {
    x = a;
    y = b;
  }
  base conj() { return base(x, -y); }
  base operator=(const base &o) {
    x = o.x;
    y = o.y;
    return *this;
  }
  base operator+(const base &o) const { return base(x + o.x, y + o.y); }
  base operator-(const base &o) const { return base(x - o.x, y - o.y); }
  base operator*(const base &o) const {
    return base(x * o.x - y * o.y, y * o.x + x * o.y);
  }
  base operator*(const double num) const { return base(x * num, y * num); }
  base operator/(const double num) const { return base(x / num, y / num); }
};
long long col[maxn];
vector<long long> adj[maxn];
long long st[maxn], ed[maxn], lzy[5 * maxn];
vector<long long> euler;
long long seg[5 * maxn], ans;
long long pow2[60];
void merge(long long a, long long b, long long c) { seg[c] = seg[a] | seg[b]; }
void build(long long node, long long s, long long e) {
  lzy[node] = -1;
  if (s == e) {
    seg[node] = (pow2[col[euler[s]] - 1]);
    return;
  }
  build(2 * node, s, (s + e) / 2);
  build(2 * node + 1, (s + e) / 2 + 1, e);
  merge(2 * node, 2 * node + 1, node);
}
void rmv(long long node, long long s, long long e) {
  if (lzy[node] == -1) return;
  seg[node] = (pow2[(lzy[node] - 1)]);
  if (s != e) {
    lzy[2 * node] = lzy[node];
    lzy[2 * node + 1] = lzy[node];
  }
  lzy[node] = -1;
}
void upd(long long node, long long s, long long e, long long l, long long r,
         long long val) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    lzy[node] = val;
    rmv(node, s, e);
    return;
  }
  upd(2 * node, s, (s + e) / 2, l, r, val);
  upd(2 * node + 1, (s + e) / 2 + 1, e, l, r, val);
  merge(2 * node, 2 * node + 1, node);
}
void quer(long long node, long long s, long long e, long long l, long long r) {
  rmv(node, s, e);
  if (l > e || r < s) return;
  if (s >= l && e <= r) {
    ans |= seg[node];
    return;
  }
  quer(2 * node, s, (s + e) / 2, l, r);
  quer(2 * node + 1, (s + e) / 2 + 1, e, l, r);
}
void df(long long no, long long p) {
  euler.push_back(no);
  st[no] = euler.size() - 1;
  for (auto x : adj[no]) {
    if (x != p) {
      df(x, no);
    }
  }
  ed[no] = euler.size() - 1;
}
signed main() {
  long long n, m, u, v, t, tt;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pow2[0] = 1;
  for (long long i = 0; i < 59; i++) {
    pow2[i + 1] = pow2[i] * 2;
  }
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> col[i];
  }
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  df(0, 0);
  build(1, 0, euler.size() - 1);
  for (long long i = 0; i < m; i++) {
    cin >> t;
    if (t == 1) {
      cin >> u >> v;
      u--;
      upd(1, 0, euler.size() - 1, st[u], ed[u], v);
    } else {
      cin >> u;
      u--;
      ans = 0;
      quer(1, 0, euler.size() - 1, st[u], ed[u]);
      tt = 0;
      for (long long i = 0; i < 60; i++) {
        if (ans & (pow2[i])) tt++;
      }
      cout << (tt) << "\n";
    }
  }
}
