let k = stdin.ReadLine() |> int

/// return newList, count, newCount
let rec createMightAnsList beforeList count =
    let newList =
        beforeList
        |> List.map (fun (a:string) -> 
            match a.[a.Length-1] with
            | '0' -> [a+"0"; a+"1"]
            | '1' -> [a+"0"; a+"1"; a+"2"]
            | '2' -> [a+"1"; a+"2"; a+"3"]
            | '3' -> [a+"2"; a+"3"; a+"4"]
            | '4' -> [a+"3"; a+"4"; a+"5"]
            | '5' -> [a+"4"; a+"5"; a+"6"]
            | '6' -> [a+"5"; a+"6"; a+"7"]
            | '7' -> [a+"6"; a+"7"; a+"8"]
            | '8' -> [a+"7"; a+"8"; a+"9"]
            | '9' -> [a+"8"; a+"9"])
        |>List.collect (fun x -> x)

    let newCount = count + newList.Length
    
    if newCount >= k then
        newList, count, newCount
    else
        createMightAnsList newList newCount

let countAns (newList:list<_>) count newCount = newList.[(k - count - 1)]

if k <= 9 then
    k.ToString()
else
    createMightAnsList 
        ([1..9] |> List.map string)
        9
    |||> countAns 
|> stdout.WriteLine