import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n= scanner.nextInt();
        int q= scanner.nextInt();
        int arr[]=new int [n+1];
        for(int i=1;i<=n;i++){
            arr[i]= scanner.nextInt();
        }
        for(int j=0;j<q;j++){
            int state= scanner.nextInt();
            int i= scanner.nextInt();
            int x= scanner.nextInt();
            if(state==1){
                arr[i]=x;
            }
            else if(state==2){
                int count=0;
                for(int m=1;m<=i;m++){
                    if(arr[m]==x){
                        count++;
                    }
                }
                System.out.println(count);
            }
        }

    }
}