#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> A, B;
  int a, b, cnt = 0;
  cin >> a;
  for (; a--;) {
    cin >> b;
    A.push_back(b);
    B.push_back(b);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < A.size(); i++) {
    if (A[i] != B[i]) {
      cnt++;
    }
  }
  cout << cnt;
}
