#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
ld PI=asin(1)*2;
//using namespace atcoder;


// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main(){
    ll H,W,M;
    cin >> H >> W >> M;
    vector<ll> X(M),Y(M);
    vector<ll> A(W+1,H), B(H+1,W);
    rep(i,M){
        cin >> X[i] >> Y[i];
        X[i]--;Y[i]--;
        cmin(A[Y[i]],X[i]);
        cmin(B[X[i]],Y[i]);
    }
    ll ans = 0;
    rep(y,B[0]){
        ans += A[y];
    }
    rep(x,A[0]){
        ans += B[x];
    }
    ll sum = 0;
    BIT<ll> tr(W);
    rep(y,B[0]) tr.add(y,1);
    vector<vector<ll> > ends(H+1);
    rep(y,B[0]) ends[A[y]].push_back(y); 
    rep(x,A[0]){
        for(auto& y:ends[x]) tr.add(y,-1);
        ans -= tr.sum(0,B[x]);
    }
    cout << ans << endl;
}
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int m=0;
int vis[109],pm[109];
int sm[109];
ll f[2][1050009];
void init()
{
	for(int i=2;i<=72;i++)
	{
		if(!vis[i])
			pm[++m]=i;
		for(int j=1;j<=m&&i*pm[j]<=72;j++)
			vis[i*pm[j]]=1;
	}
}
int main()
{
	ll a,b;
	scanf("%lld%lld",&a,&b);
	init();
	int cur=0;
	f[0][0]=1;
	for(ll i=a;i<=b;i++)
	{
		cur^=1;
		memset(f[cur],0,sizeof(f[cur]));
		int ns=0;
		for(int j=1;j<=m;j++)
			if(i%pm[j]==0)
				ns|=1<<(j-1);
		for(int s=0;s<1<<m;s++)
		{
			f[cur][s]+=f[cur^1][s];
			if((ns&s)==0)
				f[cur][ns|s]+=f[cur^1][s];
		}
	}
	ll ans=0;
	for(int s=0;s<1<<m;s++)
		ans+=f[cur][s];
	printf("%lld",ans);
	return 0;
}