#line 2 "/Users/2P/Desktop/ramstream/library/template/template.hpp" /** * @brief Header */ #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include // #include using namespace std; typedef long long ll; #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(i, n) for (int i = 0; i < int(n); ++i) #define rep2(i, s, n) for (int i = int(s); i < int(n); ++i) #define rep3(i, s, n, d) for(int i = int(s); i < int(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define fir first #define sec second #define pb push_back #define em emplace_back #define mk make_pair #define SUM(a) accumulate(all(a),0LL) #define MIN(a) *min_element(all(a)) #define MAX(a) *max_element(all(a)) template void input(T&... a){(cin >> ... >> a);} #define INT(...) int __VA_ARGS__;input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;input(__VA_ARGS__) #define STR(...) string __VA_ARGS__;input(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;input(__VA_ARGS__) void Yes(bool iSizIs=true) {if(iSizIs){cout<<"Yes"< void OUT(T x) {cout << (x) << endl;} template bool chmin(T &a, T b) {if (a > b) {a = b;return true;}return false;} template bool chmax(T &a, T b) {if (a < b) {a = b;return true;}return false;} ll POW(ll a, ll n, ll MOD) { if (n == 0) return 1; if (n == 1) return a % MOD; ll ret = POW(a, n / 2, MOD) % MOD; (ret *= ret) %= MOD; if (n % 2 == 1) { (ret *= a) %= MOD; } return ret; } const int inf = INT_MAX / 2; const ll infl = 1LL << 60; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vd = vector; using vvd = vector; using vs = vector; using vvs = vector; using vb = vector; using vvb = vector; using pii = pair; using pll = pair; using mii = map; using mll = map; #include using namespace atcoder; #line 2 "sol.cpp" int main() { int n; cin >> n; vi a(n+1); vi p(n+1); rep(i,1,n+1) cin >> a[i], p[a[i]] = i; int ans = 0; rep(i,1,n+1) { if(p[i] == i) continue; int x = p[i]; a[p[i]] = a[i]; p[i] = i; p[x] = a[i]; a[i] = i; ans++; } cout << ans << endl; }