#include <bits/stdc++.h>
using namespace std;
struct node {
  long long c;
  bool full;
};
node t[2100000];
long long color[400011];
vector<int> arc[400011];
int lp[400011], rp[400011];
int P, n, q;
void dfs(int v, int par) {
  lp[v] = P++;
  for (int w = 0; w < arc[v].size(); w++) {
    if (arc[v][w] != par) dfs(arc[v][w], v);
  }
  rp[v] = P++;
}
void change(int w, int L, int R, long long x, int l, int r) {
  if ((l > R) || (r < L)) return;
  if ((L <= l) && (r <= R)) {
    t[w].c = x;
    t[w].full = true;
    return;
  }
  if (t[w].full) {
    t[2 * w].c = t[2 * w + 1].c = t[w].c;
    t[2 * w].full = t[2 * w + 1].full = true;
    t[w].full = false;
  }
  change(2 * w, L, R, x, l, l + (r - l) / 2);
  change(2 * w + 1, L, R, x, l + (r - l) / 2 + 1, r);
  t[w].c = t[2 * w].c | t[2 * w + 1].c;
}
long long get(int w, int L, int R, int l, int r) {
  if ((l > R) || (r < L)) return 0;
  if (((L <= l) && (r <= R)) || (t[w].full)) return t[w].c;
  return (get(2 * w, L, R, l, l + (r - l) / 2) |
          get(2 * w + 1, L, R, l + (r - l) / 2 + 1, r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i;
  int a, b;
  cin >> n >> q;
  long long one = 1;
  for (i = 1; i <= n; i++) {
    cin >> a;
    color[i] = one << (a - 1);
  }
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    arc[a].push_back(b);
    arc[b].push_back(a);
  }
  dfs(1, 0);
  P = 1;
  for (i = 1; i <= n; i++) {
    change(1, lp[i], lp[i], color[i], 1, 2 * n);
    change(1, rp[i], rp[i], color[i], 1, 2 * n);
  }
  int k;
  long long col;
  long long mask;
  int cc;
  for (i = 1; i <= q; i++) {
    cin >> k;
    if (k == 1) {
      cin >> a >> b;
      change(1, lp[a], rp[a], (one << (b - 1)), 1, 2 * n);
    } else {
      cin >> a;
      col = get(1, lp[a], rp[a], 1, 2 * n);
      mask = 1;
      cc = 0;
      for (k = 1; k <= 60; k++) {
        if (col & mask) cc++;
        mask <<= 1;
      }
      cout << cc << endl;
    }
  }
}
