import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
sizediff_t minIndex(alias pred = "a < b", Range)(Range range)
if (isForwardRange!Range && !isInfinite!Range &&
    is(typeof(binaryFun!pred(range.front, range.front))))
{
    if (range.empty) return -1;

    sizediff_t minPos = 0;

    static if (isRandomAccessRange!Range && hasLength!Range)
    {
        foreach (i; 1 .. range.length)
        {
            if (binaryFun!pred(range[i], range[minPos]))
            {
                minPos = i;
            }
        }
    }
    else
    {
        sizediff_t curPos = 0;
        Unqual!(typeof(range.front)) min = range.front;
        for (range.popFront(); !range.empty; range.popFront())
        {
            ++curPos;
            if (binaryFun!pred(range.front, min))
            {
                min = range.front;
                minPos = curPos;
            }
        }
    }
    return minPos;
}


void selsort(T)(T a, out int sw)
{
    sw = 0;
    for (size_t i = 0; i < a.length; i++)
    {
        auto min = a[i..$].minIndex + i;
        if (a[i] > a[min])
        {
            swap(a[i], a[min]);
            sw++;
        }
    }
}
void main()
{
    readln;
    auto a = readln().strip.split(" ").map!(to!int).array;
    int sw;
    a.selsort(sw);
    writeln(a.map!(to!string).join(" "));
    writeln(sw);
}
