#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair int main() { int n; cin >> n; vector a(n), pre(n, -1); rep(i, n) { cin >> a[i]; a[i]--; if (i > 0) pre[a[i]] = a[i-1]; } vector used(n, true); int ans = 0; rep(i, n) { if (used[i]) { ans++; used[i] = false; if (pre[i] != -1) used[pre[i]] = false; } } cout << ans << endl; }