//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);
A = A[1].split(' ').map(Number);

cnt = sort(A);
console.log(A.join(' '));
console.log(cnt);

function sort(A) {
  var cnt, i, minj, j, tmp;
  cnt = 0;
  for (i = 0; i < A.length; i++) {
    minj = i;
    for (j = i; j < A.length; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
    if (i !== minj) cnt++;
  }
  return cnt;
}