#include <bits/stdc++.h>
using namespace std;
int n;
int v[200005];
void read();
int main() {
  read();
  int k = n - 1;
  while (v[k] == v[k + 1]) --k;
  cout << k << '\n';
  return 0;
}
void read() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> v[i];
}
