#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  b = a;
  sort(a.begin(), a.end());
  int count = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[i]) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
