def selectionsort(a)
    swapcount = 0
    (0...a.size).each{|i|
        minj = i
        (i...a.size).each{|j|
            minj = j if a[j]<a[minj]
        }
        a[i], a[minj], swapcount = a[minj], a[i], swapcount+1 if i!=minj
    }
    return swapcount
end

gets
a = gets.split.map(&:to_i)
ct = selectionsort a
puts a.join(' '), ct
