gets
a = gets.split(" ").map(&:to_i)

count = 0

x = 0
a.size.times do |i|
    x = i
    
    (i...a.size).each do |j|
        if a[j] < a[x] then
            x = j
        end
    end

    if i != x then
        a[i], a[x] = a[x], a[i]
        count += 1
    end
end

print a.join(" "), "\n"
print count, "\n"

