#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=5010;
const int MAX=1000000100;
const int mod=100000000;
const int MOD1=1000000007;
const int MOD2=1000000009;
const double EPS=0.00000001;
typedef long long ll;
const ll MOD=998244353;
const ll INF=10000000010;
typedef double db;
typedef unsigned long long ull;
struct node {
int x,y,z,id,tab;
}ope[210000],aux[210000];
int s,w;
ll f[2000010],ans[10010];
int cmp(node a,node b) {
if (a.x!=b.x) return a.x<b.x;
else if (a.y!=b.y) return a.y<b.y;
else return a.z<b.z;
}
void add(int a,ll b) {
if (!a) return ;
for (;a<=w;a+=a&(-a)) f[a]+=b;
}
ll getsum(int a) {
ll ret=0;
for (;a;a-=a&(-a)) ret+=f[a];
return ret;
}
void cdq(int l,int r) {
if (l==r) return ;
int i,mid=(l+r)>>1,L,R;
for (i=l;i<=r;i++)
if (ope[i].z<=mid&&!ope[i].id) add(ope[i].y,ope[i].tab);
else if (ope[i].z>mid&&ope[i].id) ans[ope[i].id]+=ope[i].tab*getsum(ope[i].y);
for (i=l;i<=r;i++)
if (ope[i].z<=mid&&!ope[i].id) add(ope[i].y,0-ope[i].tab);
L=l;R=mid+1;
for (i=l;i<=r;i++)
if (ope[i].z<=mid) { aux[L]=ope[i];L++; }
else { aux[R]=ope[i];R++; }
for (i=l;i<=r;i++) ope[i]=aux[i];
cdq(l,mid);cdq(mid+1,r);
}
int main()
{
int a,i,k,q,x,x1,y1,x2,y2;
scanf("%d%d", &s, &w);
k=q=0;
while (scanf("%d", &x)&&x!=3)
if (x==1) {
scanf("%d%d%d", &x1, &y1, &a);
k++;ope[k].x=x1;ope[k].y=y1;
ope[k].z=k;ope[k].id=0;ope[k].tab=a;
} else {
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
q++;ans[q]+=((ll)(y2-y1+1)*(x2-x1+1))*s;
k++;ope[k].z=k;ope[k].id=q;
ope[k].x=x2;ope[k].y=y2;ope[k].tab=1;
k++;ope[k].z=k;ope[k].id=q;
ope[k].x=x1-1;ope[k].y=y1-1;ope[k].tab=1;
k++;ope[k].z=k;ope[k].id=q;
ope[k].x=x1-1;ope[k].y=y2;ope[k].tab=-1;
k++;ope[k].z=k;ope[k].id=q;
ope[k].x=x2;ope[k].y=y1-1;ope[k].tab=-1;
}
sort(ope+1,ope+k+1,cmp);
memset(f,0,sizeof(f));
cdq(1,k);
for (i=1;i<=q;i++) printf("%lld\n", ans[i]);
return 0;
}