local k=io.read("n")

local que={1,2,3,4,5,6,7,8,9}

for i=1,k-1 do
    local pop=que[i]
    for j=-1,1 do
        local add=(pop%10)+j
        if 0<=add and add<=9 then
            table.insert(que,pop*10+add)
        end
    end
end
print(que[k])