#include <bits/stdc++.h>
using namespace std;
int arr[200000];
class TaskA {
  int n;

 public:
  void solve(int testNumber, istream& in, ostream& out) {
    in >> n;
    for (int i = 0; i < n; i++) in >> arr[i];
    int i = n - 2;
    for (; i >= 0; i--) {
      if (arr[i + 1] != arr[i]) break;
    }
    out << i + 1 << "\n";
  }
};
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  istream& in(cin);
  ostream& out(cout);
  TaskA solver;
  solver.solve(1, in, out);
  return 0;
}
