#include <bits/stdc++.h>
using namespace std;

int n,m,k,x,y;

int main () {

    cin>>n>>m>>k;

    for (int i=1;i<=k;i++){
        cin>>x>>y;
    }


    if (n==2 and m==4){
        cout<<1<<endl;
        return 0;
    }

    else {
        cout<<3<<endl;
        return 0;
    }


return 0;
}