#include <fstream>
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;
#define ALL(c) (c).begin(), (c).end()
#define REP(i,n) for(ll i=0; i < (n); ++i)
using ll = long long;
using vl = vector<ll>;
int main(){
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cout << fixed << setprecision(8);
	ll w, h; cin >> w >> h;
	ll n; cin >> n;
	vl p(n); REP(i, n) cin >> p[i];

	ll a = (w - 1) * 2 + h;
	ll b = (w - 1) * 2 + h - 4;
	ll cnt = 0;
	REP(i, n){
		(p[i] == 0 ? a : b)--;
		if (0 < a && a <= w - 1){
			if (a == b) cnt++;
		}
		else if (w < a && a <= w + h - 2){
			if (a - 2 == b) cnt++;
		}
		else if (w + h - 1 < a && a <= w * 2 + h - 2){
			if (a - 4 == b) cnt++;
		}
	}

	cout << cnt << endl;
}