#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int w, h, n;

bool adj(int a, int b) {
    if (0 <= a && a <= w - 2 &&
        0 <= b && b <= w - 2) {
        return a == b;
    }

    if (w <= a && a <= w + h - 3 &&
        w - 2 <= b && b <= w - 2 + h - 3) {
        return a - w == b - (w - 2);
    }

    if (w + h - 1 <= a &&
        w - 2 + h - 3 <= b) {
        return a - (w + h - 1) == b - (w - 2 + h - 3);
    }
    return false;
}

int main() {
    while (cin >> w >> h >> n) {
        int a = 0, b = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int p;
            cin >> p;
            if (p) b++; else a++;
            ans += adj(a, b);
        }
        cout << ans << endl;
    }
}