#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main(){
int n,v1;
string st_in;
cin>>n;
for(int i=1;i<=n;i++){
scanf("%d",&v1);
if(v1!=4){
cin>>st_in;
}
if(v1==1){
cin>>v1;
mp[st_in]=v1;
cout<<"OK\n";
}
if(v1==2){
if(mp[st_in]!=0){
cout<<mp[st_in]<<'\n';
}else{
puts("Not found");
}
}
if(v1==3){
bool fl=0;
for(auto it=mp.begin();it!=mp.end();it++){
if(it->first==st_in){
mp.erase(it);
puts("Deleted successfully");
fl=1;
break;
}
}
if(!fl){
puts("Not found");
}
}
if(v1==4){
int ans=0;
for(auto it=mp.begin();it!=mp.end();it++){
if(it->second!=0){
ans++;
}
}
cout<<ans<<'\n';
}
}
return 0;
}