#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class TheMoviesLevelOneDivOne { public:
	long long find(int n, int m, vector <int> row, vector <int> seat) 
	{
		LL all = LL(n)*LL(m-1);

		set< pair<int,int> > dead;
		for(int i=0; i<row.size(); ++i)
		{
			int y = row[i]-1;
			int x = seat[i]-1;
			if(x<m-1)dead.insert( make_pair(y,x) );
			if(x>0) dead.insert( make_pair(y,x-1) );
		}
		return all - dead.size();
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const long long& Expected, const long long& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, TheMoviesLevelOneDivOne().find(n, m, row, seat));}
int main(){

CASE(0)
	int n = 2; 
	int m = 3; 
	int row_[] = {1, 2};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	int seat_[] = {2, 3};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 1LL; 
END
CASE(1)
	int n = 2; 
	int m = 3; 
	int row_[] = {1, 1, 1, 2, 2, 2};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	int seat_[] = {1, 2, 3, 1, 2, 3};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 0LL; 
END
CASE(2)
	int n = 4; 
	int m = 7; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	int seat_[] = {1};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 23LL; 
END
CASE(3)
	int n = 10; 
	int m = 8; 
	int row_[] = {1, 9, 6, 10, 6, 7, 9, 3, 9, 2};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	int seat_[] = {7, 7, 3, 3, 7, 1, 5, 1, 6, 2};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 54LL; 
END
CASE(4)
	int n = 1; 
	int m = 1; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {1};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 0LL; 
END
CASE(5)
	int n = 1000000000; 
	int m = 1; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {1};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 0LL; 
END
CASE(6)
	int n = 1000000000; 
	int m = 100000001; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {1};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 100000000000000000LL - 1; 
END
CASE(7)
	int n = 1000000000; 
	int m = 100000001; 
	int row_[] = {2};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {1};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 100000000000000000LL - 1; 
END
CASE(8)
	int n = 1000000000; 
	int m = 100000001; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {2};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 100000000000000000LL - 2; 
END
CASE(9)
	int n = 1000000000; 
	int m = 100000001; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {100000001};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 100000000000000000LL - 1; 
END
CASE(10)
	int n = 1000000000; 
	int m = 100000001; 
	int row_[] = {1};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {100000000};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 100000000000000000LL - 2; 
END
CASE(11)
	int n = 3; 
	int m = 3; 
	int row_[] = {1,2,3};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {2,2,2};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 0LL;
END
CASE(12)
	int n = 3; 
	int m = 3; 
	int row_[] = {1,2,3,2,2};
	  vector <int> row(row_, row_+sizeof(row_)/sizeof(*row_)); 
	  int seat_[] = {1,2,3,1,3};
	  vector <int> seat(seat_, seat_+sizeof(seat_)/sizeof(*seat_)); 
	long long _ = 2LL;
END
}
// END CUT HERE
