#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
  return sum;
}
int n, q;
int w[500010], s[500010];
const int inf = 2e9;
struct seg_tree {
  int mmin[500010 << 3], sum[500010 << 3], lz[500010 << 3], va[500010 << 3];
  void gai(int now, int t) {
    mmin[now] += t;
    lz[now] += t;
  }
  void build(int now, int l, int r) {
    mmin[now] = inf;
    if (l == r) return;
    int mid = l + r >> 1;
    build(now << 1, l, mid);
    build(now << 1 | 1, mid + 1, r);
  }
  void pushdown(int now) {
    if (!lz[now]) return;
    gai(now << 1, lz[now]);
    gai(now << 1 | 1, lz[now]);
    lz[now] = 0;
  }
  void up(int now) {
    mmin[now] = min(mmin[now << 1], mmin[now << 1 | 1]);
    sum[now] = 0;
    if (mmin[now << 1] == mmin[now]) sum[now] += sum[now << 1];
    if (mmin[now << 1 | 1] == mmin[now]) sum[now] += sum[now << 1 | 1];
  }
  void modify(int now, int l, int r, int ll, int rr, int t) {
    if (ll <= l && r <= rr) {
      va[now] += t;
      gai(now, t);
      return;
    }
    pushdown(now);
    int mid = l + r >> 1;
    if (ll <= mid) modify(now << 1, l, mid, ll, rr, t);
    if (rr >= mid + 1) modify(now << 1 | 1, mid + 1, r, ll, rr, t);
    up(now);
  }
  void upd(int now, int l, int r, int t, int d, int q) {
    q += va[now];
    if (l == r) {
      sum[now] += d;
      if (!sum[now])
        mmin[now] = inf;
      else
        mmin[now] = q;
      return;
    }
    pushdown(now);
    int mid = l + r >> 1;
    if (t <= mid)
      upd(now << 1, l, mid, t, d, q);
    else
      upd(now << 1 | 1, mid + 1, r, t, d, q);
    up(now);
  }
  pair<int, int> query(int now, int l, int r, int t) {
    if (l == r) return make_pair(mmin[now], sum[now]);
    pushdown(now);
    int mid = l + r >> 1;
    if (t <= mid)
      return query(now << 1, l, mid, t);
    else
      return query(now << 1 | 1, mid + 1, r, t);
  }
} S;
void out(pair<int, int> a) { cout << a.first << " " << a.second << " "; }
const int maxn = 1e6 + 10;
void UPD(int id, int f) {
  if (w[id - 1] > w[id]) S.modify(1, 0, maxn + 1, w[id], w[id - 1] - 1, f);
  if (w[id] > w[id + 1]) S.modify(1, 0, maxn + 1, w[id + 1], w[id] - 1, f);
  S.upd(1, 0, maxn + 1, w[id], f, 0);
}
int main() {
  n = read(), q = read();
  S.build(1, 0, maxn + 1);
  w[0] = maxn + 1;
  w[n + 1] = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (i <= n) {
      w[i] = read(), S.upd(1, 0, maxn + 1, w[i], 1, 0);
    }
    if (w[i] < w[i - 1]) S.modify(1, 0, maxn + 1, w[i], w[i - 1] - 1, 1);
  }
  for (int i = 1; i <= q; i++) {
    int id = read(), val = read();
    UPD(id, -1);
    w[id] = val;
    UPD(id, 1);
    int a = 0;
    if (S.mmin[1] == 1) a = S.sum[1];
    cout << a << '\n';
  }
  return 0;
}
