#include constexpr int kN = int(1E5 + 10), kInf = int(1E9 + 10); struct seg_tree { int val[kN << 2]; long long int flag[kN << 2], left[kN << 2], right[kN << 2]; void pull(int n) { val[n] = val[n * 2 + 1] + val[n * 2 + 2]; if (left[n * 2 + 2] != right[n * 2 + 1]) val[n]++; return ; } void addtag(int n, int x) { left[n] += x; right[n] += x; flag[n] += x; return ; } void push(int n) { if (flag[n]) { addtag(n * 2 + 1, flag[n]); addtag(n * 2 + 2, flag[n]); flag[n] = 0; } return ; } void init(int n, int l, int r, int a[]) { flag[n] = 0; if (l == r) { val[n] = 0; left[n] = right[n] = a[l]; } else { int mid = (l + r) >> 1; init(n * 2 + 1, l, mid, a); init(n * 2 + 2, mid + 1, r, a); pull(n); } return ; } void fix(int n, int l, int r, int L, int R, int x) { if (L <= l && r <= R) addtag(n, x); else if (!(L > r || l > R)){ int mid = (l + r) >> 1; push(n); fix(n * 2 + 1, l, mid, L, R, x); fix(n * 2 + 2, mid + 1, r, L, R, x); pull(n); } return ; } int ask(int n, int l, int r, int L, int R, long long int &lv, long long int &rv) { if (L <= l && r <= R) { lv = left[n]; rv = right[n]; return val[n]; } else if (L > r || l > R) { lv = rv = -1; return 0; } else { push(n); int mid = (l + r) >> 1, ans; long long int ll, lr, rl, rr; ans = ask(n * 2 + 1, l, mid, L, R, ll, lr) + ask(n * 2 + 2, mid + 1, r, L, R, rl, rr); if (lr != rl && lr != -1 && rl != -1) ans++; lv = ll; rv = rr; return ans; } } }; seg_tree sg; int a[kN]; int main () { int n, q, l, r, k, x; long long int p; scanf("%d%d", &n, &q); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); sg.init(0, 1, n, a); while (q--) { scanf("%d%d%d", &k, &l, &r); if (k == 1) { scanf("%d", &x); sg.fix(0, 1, n, l, r, x); } else printf("%d\n", sg.ask(0, 1, n, l, r, p, p) + 1); } }