//
// Created by gary on 27.07.17.
//

#include <bits/stdc++.h>

using namespace std;

#define SZ(x) ((int) (x).size())

const int N = 223456;

int a[N];

int c[N];
int cov[N];

int covered = 0;

void update(int i, int x) {
    if (i <= 0)
        return;
    if (cov[i] == 0) covered++;
    cov[i] += x;
    if (cov[i] == 0) covered--;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, q;
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        update(a[i] - c[a[i]]++, +1);
    }

    for (int it = 0; it < q; it++) {
        int i, x;
        scanf("%d%d", &i, &x);
        i--;
        update(a[i] - --c[a[i]], -1);
        a[i] = x;
        update(a[i] - c[a[i]]++, +1);
        printf("%d\n", n - covered);
    }
    return 0;
}
