#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > vect(500000);
long long counter = 1;
pair<long long, long long> range[500000];
void bfs(long long parent, long long node) {
  range[node].first = counter;
  for (auto &child : vect[node]) {
    if (child != parent) {
      bfs(node, child);
    }
  }
  range[node].second = counter;
  counter++;
}
bitset<62> tree[4000000];
long long lazy[4000000];
bitset<62> query(bitset<62> tree[], long long l, long long r, long long L,
                 long long R, long long node) {
  if (lazy[node] != 0) {
    tree[node].reset();
    tree[node][lazy[node]] = 1;
    lazy[node * 2] = lazy[node];
    lazy[node * 2 + 1] = lazy[node];
    lazy[node] = 0;
  }
  if (l <= L && R <= r) {
    return tree[node];
  } else if (r < L || R < l) {
    bitset<62> temp;
    temp.reset();
    return temp;
  } else {
    long long mid;
    mid = (L + R) / 2;
    bitset<62> temp = query(tree, l, r, L, mid, node * 2);
    temp |= query(tree, l, r, mid + 1, R, node * 2 + 1);
    tree[node] = tree[node * 2];
    tree[node] |= tree[node * 2 + 1];
    return temp;
  }
}
void update(bitset<62> tree[], long long l, long long r, long long L,
            long long R, long long node, long long color) {
  if (lazy[node] != 0) {
    tree[node].reset();
    tree[node][lazy[node]] = 1;
    lazy[node * 2] = lazy[node];
    lazy[node * 2 + 1] = lazy[node];
    lazy[node] = 0;
  }
  if (l <= L && R <= r) {
    tree[node].reset();
    tree[node][color] = 1;
    lazy[node * 2] = color;
    lazy[node * 2 + 1] = color;
    lazy[node] = 0;
  } else if (r < L || R < l) {
  } else {
    long long mid;
    mid = (L + R) / 2;
    update(tree, l, r, L, mid, node * 2, color);
    update(tree, l, r, mid + 1, R, node * 2 + 1, color);
    tree[node] = tree[node * 2];
    tree[node] |= tree[node * 2 + 1];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  memset(lazy, 0, sizeof(lazy));
  long long u, v;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    vect[u].push_back(v);
    vect[v].push_back(u);
  }
  bfs(0, 1);
  for (long long i = 1; i < n + 1; i++) {
    update(tree, range[i].second, range[i].second, 1, n, 1, a[i]);
  }
  while (m--) {
    long long type;
    cin >> type;
    if (type == 1) {
      long long v, c;
      cin >> v >> c;
      long long l = range[v].first, r = range[v].second;
      update(tree, l, r, 1, n, 1, c);
    } else {
      long long v;
      cin >> v;
      long long l = range[v].first, r = range[v].second;
      bitset<62> ans = query(tree, l, r, 1, n, 1);
      cout << ans.count() << "\n";
    }
  }
}
