#include using namespace std; int v[300010]; int ind[300010]; int main(){ int n, tmp, count, poz; while(cin >> n){ count =0; for(int i=1; i < 300010; i++) v[i] = 0; for(int i=1; i <= n; i++){ cin >> v[i]; ind[v[i]] = i; } for(int i=1; i <= n; i++){ if(v[i] != i){ poz = ind[i]; v[poz] = v[i]; ind[v[i]] = poz; ++count; /* tmp = v[v[i]]; cout << tmp << " za " << v[i] << "\n"; v[v[i]] = v[i]; v[i] = tmp; count++; */ } } cout << count << "\n"; } return 0; }