#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool is, ara[n];
  int i;
  for (i = 0; i < n; i++) cin >> ara[i];
  is = ara[n - 1];
  for (i = n - 1; i >= 0; i--) {
    if (ara[i] != is) break;
  }
  cout << i + 1 << endl;
  return 0;
}
