n,q=map(int,input().split())
A=list(map(int,input().split()))
for _ in range(q):
    t,x=map(int,input().split())
    x-=1
    if t==1:
        A[x],A[x+1]=A[x+1],A[x]
    else:
        C=[0]*n
        w0=A[0]
        w=A[0]
        C[0]=1
        z=1
        while C[x]==0:
            for i in range(n):
                if C[i]==0 and w!=A[i]:
                    C[i]=1
                    w=A[i]
                    z+=1
                    break
            if w0==w:
                break
            w0=w
        if C[x]==0:
            for i in range(n):
                if C[i]==0:
                    z+=1
                    if i==x:
                        break
        print(z)
        
                    
    

