#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  int n, b, a;
  cin >> n >> b >> a;
  vector<int> s(n, 0);
  for (int i = 0; i < n; i++) cin >> s[i];
  int cpos = 0;
  int cb = b;
  int ca = a;
  while (cpos < n) {
    if (s[cpos] == 0) {
      if (ca > 0) {
        ca--;
        cpos++;
        ans++;
        continue;
      }
      if (cb > 0) {
        cb--;
        cpos++;
        ans++;
        continue;
      }
      break;
    } else {
      if (ca == a) {
        ans++;
        cpos++;
        ca--;
        continue;
      }
      if (cb > 0) {
        cb--;
        cpos++;
        ans++;
        ca++;
        continue;
      }
      if (ca > 0) {
        ans++;
        cpos++;
        ca--;
        continue;
      }
      break;
    }
  }
  cout << ans << "\n";
}
