from collections import deque
import sys


def main():
    n, q = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))

    def g(a):
        d = deque()
        p = [0] * len(a)
        k = 0
        l = a[0]
        p[0] = 1
        k = 1
        for i in range(1, len(a)):
            if a[i] == l:
                d.append(i)
            else:
                k += 1
                p[i] = k
                l = a[i]
                while d and a[d[0]] != l:
                    x = d.popleft()
                    k += 1
                    p[x] = k
                    l = a[x]
        while d and a[d[0]] != l:
            x = d.popleft()
            k += 1
            p[x] = k
            l = a[x]
        while d:
            x = d.popleft()
            k += 1
            p[x] = k
        return p

    for _ in range(q):
        t, x = map(int, sys.stdin.readline().split())
        if t == 1:
            a[x - 1], a[x] = a[x], a[x - 1]
        else:
            p = g(a)
            print(p[x - 1])


if __name__ == '__main__':
    main()
