#include <bits/stdc++.h>   using namespace std;   int parent[200005], par[200005], root;   int find(int i) {     if (parent[i] != i) parent[i] = find(parent[i]);     return parent[i];   }   void merge(int x, int y) {     int xroot = find(x);     int yroot = find(y);     if (xroot == yroot) {       if (!root) root = xroot;       par[x] = root;     } else       parent[xroot] = yroot;   }   int main() {     int n, temp[200005], dsu[200005], k = 0, cnt = 0;     cin >> n;     for (int i = 1; i <= n; i++) parent[i] = i;     for (int i = 1; i <= n; i++) {       cin >> par[i];       temp[i] = par[i];       if (par[i] == i) root = i;     }     for (int i = 1; i <= n; i++) {       if (par[i] == i) {         if (i == root) {         } else           par[i] = root;       } else         merge(i, par[i]);     }     for (int i = 1; i <= n; i++)       if (temp[i] != par[i]) cnt++;     cout << cnt <<   n ;     for (int i = 1; i <= n; i++) cout << par[i] <<    ;     return 0;   }   