import sys


def main():
    n, q = map(int, sys.stdin.readline().split())
    a = [0] + list(map(int, sys.stdin.readline().split()))
    o = []
    for _ in range(q):
        t, x = map(int, sys.stdin.readline().split())
        if t == 1:
            a[x], a[x + 1] = a[x + 1], a[x]
        else:
            y = x
            if y == 1:
                o.append('1')
                continue
            b = []
            h = 0
            k = 1
            c = a[1]
            i = 2
            z = 0
            while 1:
                m = len(b)
                while h < m:
                    j = b[h]
                    if a[j] == c:
                        break
                    h += 1
                    k += 1
                    c = a[j]
                    if j == y:
                        o.append(str(k))
                        z = 1
                        break
                if z:
                    break
                if i <= n:
                    v = a[i]
                    if v != c:
                        k += 1
                        c = v
                        if i == y:
                            o.append(str(k))
                            break
                    else:
                        b.append(i)
                    i += 1
                else:
                    while h < len(b):
                        j = b[h]
                        h += 1
                        k += 1
                        if j == y:
                            o.append(str(k))
                            z = 1
                            break
                    if x:
                        break
                    break
    sys.stdout.writelines('\n'.join(o))


if __name__ == '__main__':
    main()
