#include using namespace std; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int k = n; int ans = 0; for (int i = n - 1; i >= 0; i--) { if (a[i] == k) { k--; } else ans++; } cout << ans << endl; }