#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

ll gcdf(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcdf(b, a % b);
}

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll allmin = INF;
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
        allmin = min(a[i], allmin);
    }

    unordered_map<ll, ll> curgcd;
    for (auto ai : a) {
        vector<ll> succeeded;
        for (auto d : divisor(ai)) {
            if (d > allmin) continue;
            if (curgcd.count(d)) {
                curgcd[d] = gcdf(curgcd[d], ai);
            } else {
                curgcd[d] = ai;
            }
        }
    }
    ll ans = 0;
    for (auto x : curgcd) {
        ans += (x.first == x.second);
    }
    print(ans);
}

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;


 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}

int add (LL var1, LL var2) {
    return ( (var1 % mod) + (var2 % mod) + mod) % mod;
}

int mul (LL var1, LL var2) {
    return (var1*var2) % mod;
}

int powm (LL x, LL y) {
    int ans = 1;
    while (y) {
        if (y & 1) {
            ans = mul(ans, x);
        }
        x = mul(x, x);
        y /= 2;
    }
    return ans;
}

int inv(LL x) {
    return powm(x, mod-2);
}

LL INF=1e9;

void solve() {
    LL r, c, m;
    read(r,c,m);
    vector <set <int> > rows(r);
    vector <set <int> > cols(c);
    REP (i, 1, m) {
        int x, y;
        read(x,y);
        x--;
        y--;
        rows[x].insert(y);
        cols[y].insert(x);
    }
    REP(i,0,r-1) rows[i].insert(c);
    REP(i,0,c-1) cols[i].insert(r);

    LL down = *cols[0].begin();
    LL right = *rows[0].begin();
    LL ans = 0;
    REP (i, 0, down-1)
    {
        LL mxr = *rows[i].begin();
        ans += mxr;
    }
    ordered_set<int> done;
    REP (i, down, r-1) {
        done.insert(i);
    }
    REP (j, 0, right-1) {
        ans += done.order_of_key(*cols[j].begin());
        for (auto x : cols[j]) {
            done.insert(x);
        }
    }
    cout << ans << nl;

}

int main() {
    fast;
        solve();
}
