#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long int spf[100001];
void sieve() {
  spf[1] = 1;
  for (auto i = 2; i < 100001; i++) spf[i] = i;
  for (auto i = 4; i < 100001; i += 2) spf[i] = 2;
  for (auto i = 3; i * i < 100001; i++) {
    if (spf[i] == i) {
      for (auto j = i * i; j < 100001; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
  return;
}
vector<long long int> getFactorization(long long int x) {
  vector<long long int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
int DecreasingArray(vector<long long int> a) {
  int n = a.size();
  int sum = 0, dif = 0;
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < n; i++) {
    if (!pq.empty() && pq.top() < a[i]) {
      dif = a[i] - pq.top();
      sum += dif;
      pq.pop();
      pq.push(a[i]);
    }
    pq.push(a[i]);
  }
  return sum;
}
void check() {
  long long int n, ans = 0;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) ans++;
  cout << ans << "\n";
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1;
  while (t--) check();
  return 0;
}
