#include <bits/stdc++.h>
using namespace std;
void bang() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto& i : v) cin >> i;
  vector<int> temp;
  temp = v;
  sort(temp.begin(), temp.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (temp[i] != v[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  bang();
  return 0;
}
