#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
long long v[N + 10];
int main() {
  long long n;
  cin >> n;
  long long cnt = 0;
  long long ara[n + 1];
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    cin >> ara[i];
    v.push_back(ara[i]);
  }
  sort(ara, ara + n);
  for (long long i = 0; i < n; i++) {
    if (ara[i] != v[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
