#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pll pair<ll,ll>
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
inline pll operator-(pll a,pll b){
return pll(a.f-b.f,a.s-b.s);
}
inline ll cross(pll a,pll b){
return a.f*b.s-a.s*b.f;
}
inline ll dot(pll a,pll b){
return a.f*b.f+a.s*b.s;
}
inline int ori(pll a,pll b,pll c){
ll ans=cross(b-a,c-a);
return (ans==0?0:(ans<0?-1:1));
}
inline bool btw(pll a,pll b,pll c){
return (ori(a,b,c)==0 and dot(a-b,c-b)<=0);
}
inline bool intersect(pll a,pll b,pll c,pll d){
if(btw(a,c,b)||btw(a,d,b)||btw(c,a,d)||btw(c,b,d)) return true;
return (ori(a,b,c)*ori(a,b,d)<0 and ori(c,d,a)*ori(c,d,b)<0);
}
inline bool comp(pair<pll,int> a,pair<pll,int> b){
#define is_neg(x) (x.s<0 or (x.s==0 and x.f<0))
int A=is_neg(a.f);
int B=is_neg(b.f);
if(A!=B){
return A>B;
}
int res=ori(pll(0,0),a.f,b.f);
if(res>0) return true;
else if(res<0) return false;
else return a.s<b.s;
}
struct BIT{
vector<int> bit;
int n;
BIT(int _n){
n=_n;
bit.resize(n+1);
}
void update(int pos,int val){
pos++;
for(;pos<=n;pos+=(pos&-pos)){
bit[pos]+=val;
}
}
int query(int pos){
pos++;
int ans=0;
for(;pos>0;pos-=(pos&-pos)){
ans+=bit[pos];
}
return ans;
}
};
int main() {_
int n,m;
cin>>n>>m;
vector<pll> a(n),b(m);
for(int i=0;i<n;i++){
cin>>a[i].f>>a[i].s;
}
for(int i=0;i<m;i++){
cin>>b[i].f>>b[i].s;
}
sort(all(b));
ll ans=0;
vector<int> ord(m);
for(int i=0;i<m;i++){
vector<pair<pll,int>> pt;
for(int j=i+1;j<m;j++){
pt.push_back({b[j]-b[i],j});
}
sort(all(pt),comp);
int sz=(int)pt.size();
BIT bit(sz);
for(int i=0;i<sz;i++){
ord[pt[i].s]=i;
}
int r=i+1;
for(int j=0;j<n-1;j++){
if(a[j].f<b[i].f) continue;;
while(r<m and b[r].f<=a[j+1].f){
bit.update(ord[r],1);
r++;
}
int l=lower_bound(all(b),pll(a[j].f,-1))-b.begin();
l=max(l,i+1);
for(int k=l;k<r;k++){
if(intersect(b[i],b[k],a[j],a[j+1])) ans++;
}
pll L=a[j]-b[i];
pll R=a[j+1]-b[i];
if(comp(make_pair(R,-1),make_pair(L,-1))) swap(L,R);
int tl=lower_bound(all(pt),make_pair(L,-1),comp)-pt.begin();
int tr=upper_bound(all(pt),make_pair(R,m),comp)-pt.begin()-1;
//cout<<i<<' '<<j<<' '<<tl<<' '<<tr<<'\n';
if(tl<=tr) ans+=(tr-tl+1)-(bit.query(tr)-bit.query(tl-1));
}
//cout<<ans<<'\n';
}
for(int i=0;i<m;i++){
int pos=-1;
for(int j=0;j<n-1;j++){
if(a[j].f<b[i].f and a[j+1].f>=b[i].f){
pos=j;
}
}
if(pos==-1) continue;
for(int j=i+1;j<m;j++){
//if(intersect(b[i],b[j],a[pos],a[pos+1])) ans++;
}
}
cout<<ans<<'\n';
return 0;
}
//maybe its multiset not set
//yeeorz
//diaoborz
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zIikKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgcGlpIHBhaXI8aW50LGludD4KI2RlZmluZSBmIGZpcnN0CiNkZWZpbmUgcyBzZWNvbmQKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLHguZW5kKCkKI2RlZmluZSBfIGlvczo6c3luY193aXRoX3N0ZGlvKDApOyBja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maW5lIGlzX25lZyh4KSAoeC5zPDAgb3IgKHgucz09MCBhbmQgeC5mPDApKQogICAgaW50IEE9aXNfbmVnKGEuZik7CiAgICBpbnQgQj1pc19uZWcoYi5mKTsKICAgIGlmKEEhPUIpewogICAgICAgIHJldHVybiBBPkI7CiAgICB9CiAgICBpbnQgcmVzPW9yaShwbGwoMCwwKSxhLmYsYi5mKTsKICAgIGlmKHJlcz4wKSByZXR1cm4gdHJ1ZTsKICAgIGVsc2UgaWYocmVzPDApIHJldHVybiBmYWxzZTsKICAgIGVsc2UgcmV0dXJuIGEuczxiLnM7Cn0KCnN0cnVjdCBCSVR7CiAgICB2ZWN0b3I8aW50PiBiaXQ7CiAgICBpbnQgbjsKICAgIEJJVChpbnQgX24pewogICAgICAgIG49X247CiAgICAgICAgYml0LnJlc2l6ZShuKzEpOwogICAgfQogICAgdm9pZCB1cGRhdGUoaW50IHBvcyxpbnQgdmFsKXsKICAgICAgICBwb3MrKzsKICAgICAgICBmb3IoO3Bvczw9bjtwb3MrPShwb3MmLXBvcykpewogICAgICAgICAgICBiaXRbcG9zXSs9dmFsOwogICAgICAgIH0KICAgIH0KICAgIGludCBxdWVyeShpbnQgcG9zKXsKICAgICAgICBwb3MrKzsKICAgICAgICBpbnQgYW5zPTA7CiAgICAgICAgZm9yKDtwb3M+MDtwb3MtPShwb3MmLXBvcykpewogICAgICAgICAgICBhbnMrPWJpdFtwb3NdOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYW5zOwogICAgfQp9OwoKaW50IG1haW4oKSB7XwogICAgaW50IG4sbTsKICAgIGNpbj4+bj4+bTsKICAgIHZlY3RvcjxwbGw+IGEobiksYihtKTsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGNpbj4+YVtpXS5mPj5hW2ldLnM7CiAgICB9CiAgICBmb3IoaW50IGk9MDtpPG07aSsrKXsKICAgICAgICBjaW4+PmJbaV0uZj4+YltpXS5zOwogICAgfQogICAgc29ydChhbGwoYikpOwogICAgbGwgYW5zPTA7CiAgICB2ZWN0b3I8aW50PiBvcmQobSk7CiAgICBmb3IoaW50IGk9MDtpPG07aSsrKXsKICAgICAgICB2ZWN0b3I8cGFpcjxwbGwsaW50Pj4gcHQ7CiAgICAgICAgZm9yKGludCBqPWkrMTtqPG07aisrKXsKICAgICAgICAgICAgcHQucHVzaF9iYWNrKHtiW2pdLWJbaV0san0pOwogICAgICAgIH0KICAgICAgICBzb3J0KGFsbChwdCksY29tcCk7CiAgICAgICAgaW50IHN6PShpbnQpcHQuc2l6ZSgpOwogICAgICAgIEJJVCBiaXQoc3opOwogICAgICAgIGZvcihpbnQgaT0wO2k8c3o7aSsrKXsKICAgICAgICAgICAgb3JkW3B0W2ldLnNdPWk7CiAgICAgICAgfQogICAgICAgIGludCByPWkrMTsKICAgICAgICBmb3IoaW50IGo9MDtqPG4tMTtqKyspewogICAgICAgICAgICBpZihhW2pdLmY8YltpXS5mKSBjb250aW51ZTs7CiAgICAgICAgICAgIHdoaWxlKHI8bSBhbmQgYltyXS5mPD1hW2orMV0uZil7CiAgICAgICAgICAgICAgICBiaXQudXBkYXRlKG9yZFtyXSwxKTsKICAgICAgICAgICAgICAgIHIrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBpbnQgbD1sb3dlcl9ib3VuZChhbGwoYikscGxsKGFbal0uZiwtMSkpLWIuYmVnaW4oKTsKICAgICAgICAgICAgbD1tYXgobCxpKzEpOwogICAgICAgICAgICBmb3IoaW50IGs9bDtrPHI7aysrKXsKICAgICAgICAgICAgICAgIGlmKGludGVyc2VjdChiW2ldLGJba10sYVtqXSxhW2orMV0pKSBhbnMrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBwbGwgTD1hW2pdLWJbaV07CiAgICAgICAgICAgIHBsbCBSPWFbaisxXS1iW2ldOwogICAgICAgICAgICBpZihjb21wKG1ha2VfcGFpcihSLC0xKSxtYWtlX3BhaXIoTCwtMSkpKSBzd2FwKEwsUik7CiAgICAgICAgICAgIGludCB0bD1sb3dlcl9ib3VuZChhbGwocHQpLG1ha2VfcGFpcihMLC0xKSxjb21wKS1wdC5iZWdpbigpOwogICAgICAgICAgICBpbnQgdHI9dXBwZXJfYm91bmQoYWxsKHB0KSxtYWtlX3BhaXIoUixtKSxjb21wKS1wdC5iZWdpbigpLTE7CiAgICAgICAgICAgIC8vY291dDw8aTw8JyAnPDxqPDwnICc8PHRsPDwnICc8PHRyPDwnXG4nOwogICAgICAgICAgICBpZih0bDw9dHIpIGFucys9KHRyLXRsKzEpLShiaXQucXVlcnkodHIpLWJpdC5xdWVyeSh0bC0xKSk7CiAgICAgICAgfQogICAgICAgIC8vY291dDw8YW5zPDwnXG4nOwogICAgfQogICAgZm9yKGludCBpPTA7aTxtO2krKyl7CiAgICAgICAgaW50IHBvcz0tMTsKICAgICAgICBmb3IoaW50IGo9MDtqPG4tMTtqKyspewogICAgICAgICAgICBpZihhW2pdLmY8YltpXS5mIGFuZCBhW2orMV0uZj49YltpXS5mKXsKICAgICAgICAgICAgICAgIHBvcz1qOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmKHBvcz09LTEpIGNvbnRpbnVlOwogICAgICAgIGZvcihpbnQgaj1pKzE7ajxtO2orKyl7CiAgICAgICAgICAgIC8vaWYoaW50ZXJzZWN0KGJbaV0sYltqXSxhW3Bvc10sYVtwb3MrMV0pKSBhbnMrKzsKICAgICAgICB9CiAgICB9CiAgICBjb3V0PDxhbnM8PCdcbic7CiAgICByZXR1cm4gMDsKfQovL21heWJlIGl0cyBtdWx0aXNldCBub3Qgc2V0Ci8veWVlb3J6Ci8vZGlhb2Jvcno=