#include<bits/stdc++.h>
using namespace std;
int main()
{
	freopen("employ.in","t",stdin);
	freopen("employ.out","w",stdout);
	int n,m,s,c,i,q;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>s;
	for(int i=1;i<=n;i++)
	cin>>c;
	if(s=1)
	{
		q==n-1;
	}
	if(n=c+q)
	{
		q==n-1;
	}
	while(q<=m)
	{
		q==m; 
	}
	cout<<q*(q-1)<<endl;
	return 0; 
}
