///
///    "Excuse me... What did you say about my hair?!"
///
///                                    -Josuke Higashikata

#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(int x = (l); x < (r); ++x)
#define LoopR(x, l, r) for(int x = (r)-1; x >= (l); --x)
#define all(x) x.begin(), x.end()
#define Kill(x) exit((cout << (x) << '\n', 0))
#define YN(flag) ((flag)? "YES": "NO")
#define F first
#define S second
typedef          long long   ll;
typedef unsigned long long  ull;
typedef std::pair<int,int>  pii;
typedef std::pair<ll ,ll >  pll;
using namespace std;
//#pragma GCC optimize("O0")

#pragma GCC optimize("O0")
//#pragma GCC target("avx2")
typedef int ymm __attribute__((vector_size(32)));
const int N = 100'020;
int a[N];
ull b[N];

#pragma GCC push_options
#pragma GCC optimize("O0")
ll Do(int l, int r, int t)
{
    if(l >= r) return 0;
    ll ans;
    asm(
        ".intel_syntax;"
        "mov %%rcx, 0;"
        "mov %%r10, 0;"
        "mov %%r11, %%rbx;"
        "mov %%r12, 0x1;"
        "shl %%r12, 32;"
        "mov %%r8, 0;"
        "back:"
        "vmovdqu %%ymm0, YMMWORD PTR [%%rax];"

        "vpextrd %%r8d, %%xmm0, 0;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z1;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z1:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 1;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z2;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z2:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 2;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z3;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z3:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 3;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z4;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z4:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vextracti128 %%xmm0, %%ymm0, 0x1;"
        "vpextrd %%r8d, %%xmm0, 0;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z5;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z5:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 1;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z6;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z6:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 2;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z7;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z7:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "vpextrd %%r8d, %%xmm0, 3;"
        "mov %%r9, b[%%r8*8];"
        "cmp %%r9d, %%ebx;"
        "jne z8;"
        "add %%rcx, %%r10;"
        "shr %%r9, 32;"
        "sub %%rcx, %%r9;"
        "z8:;"
        "mov b[%%r8*8], %%r11;"
        "add %%r10, 0x1;"
        "add %%r11, %%r12;"

        "add %%rax, 32;"
        "cmp %%rax, %%rdx;"
        "jne back;"

        ".att_syntax;"
        : "=c"(ans)
        : "a"(a+l), "b"(t), "d"(a+r)
    );
    return ans;
}
#pragma GCC pop_options

int main()
{
    FAST;
    int n, m;
    cin >> n >> m; ++m;
    Loop(i,0,n)
        cin >> a[i];
    Loop(t,1,m)
    {
        int _, x, y;
        cin >> _ >> x >> y; --x;
        if(_ == 1)
        {
            a[x] = y;
        }
        else
        {
            ll ans = 0;
            int y2 = ((y-x)&(0xfffffff8))+x;
            ans += Do(x, y2, t);
            Loop(i,y2,y)
            {
                if((b[a[i]] & 0xffffffff) == t)
                {
                    ans += i - (b[a[i]] >> 32);
                }
                b[a[i]] = t ^ ((ull)i<<32);
            }
            cout << ans << '\n';
        }
    }
}
