/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int bit[10000005];
int limit = 10000004;
int arr[200005];
map<int, int> m;
void update(int start, int limit, int value)
{
for (; start <= limit; start += start & (-start))
bit[start] += value;
}
int query(int start)
{
int sum = 0;
for (; start > 0; start -= start & (-start))
sum += bit[start];
return sum;
}
int helper(int value)
{
int x = value / 100;
int ans = 0;
if (x != 0)
ans += query(x);
int value1 = x * 100;
while (value1 <= value)
{
ans += m[value1];
value1++;
}
return ans;
}
int main()
{
fastio();
#ifndef ONLINE_JUDGE
freopen("Inp.txt", "r", stdin);
freopen("Output.txt", "w", stdout);
freopen("Error.txt", "w", stderr);
#endif
for (int i = 0; i <= 10000004; i++)
bit[i] = 0;
int n, q;
cin >> n >> q;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
update(arr[i] / 100 + 1, limit, 1);
m[arr[i]]++;
}
while (q--)
{
char ch;
cin >> ch;
if (ch == '!')
{
int k;
int value;
cin >> k >> value;
k--;
update(arr[k] / 100 + 1, limit, -1);
update(value / 100 + 1, limit, 1);
m[arr[k]]--;
arr[k] = value;
m[arr[k]]++;
}
else
{
int a, b;
cin >> a >> b;
ll ans1 = helper(b);
ll ans2 = helper(a - 1);
cout << ans1 - ans2 << "\n";
}
}
return 0;
}
LyogUHJpeWFuc2ggQWdhcndhbCovCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8dW5vcmRlcmVkX21hcD4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTx1bm9yZGVyZWRfc2V0PgojaW5jbHVkZTxzZXQ+CiNpbmNsdWRlPG1hcD4KI2luY2x1ZGU8cXVldWU+CiNpbmNsdWRlPHN0YWNrPgojaW5jbHVkZTxtYXA+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZmFzdGlvKCkgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7Y2luLnRpZShOVUxMKTtjb3V0LnRpZShOVUxMKQojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgTU9EMSA5OTgyNDQzNTMKI2RlZmluZSBubGluZSAiXG4iCiNkZWZpbmUgcGIgcHV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