#define _USE_MATH_DEFINES

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<iostream>
#include<fstream>
#include<iomanip>

using namespace std;

int W, H, N;
int data[100];

int main(){
	scanf("%d%d%d", &W, &H, &N);
	for (int i = 0; i < N; ++i){
		scanf("%d", &data[i]);
	}

	int cnt = 0;
	int curAx = 1, curAy = 1;
	int curBx = 1, curBy = 2;
	for (int i = 0; i < N; ++i) {
		if (data[i] == 0) {
			if (curAy == 1 && curAx != W)  {
				curAx++;
			}
			else if (curAx == W && curAy < H) {
				curAy++;
			}
			else if (curAy == H) {
				curAx--;
			}
		}
		else {
			if (curBy == 2 && curBx != W - 1) {
				curBx++;
			}
			else if (curBx == W - 1 && curBy < H - 1) {
				curBy++;
			}
			else if (curBy == H - 1) {
				curBx--;
			}
		}

		if (curAx == curBx && ((curAy == 1 && curBy == 2) || (curAy == H && curBy == H-1))) {
			++cnt;
		}
		else if (curAy == curBy && curAx - curBx == 1) {
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}