local k = io.read("*n")
local dig = 1
local dp = {}
dp[1] = {}
for i = 1, 10 do
  dp[1][i] = 1
end
-- dp[1][10] = 0
if k <= 9 then
  print(k)
else
  local sum = 9
  while true do
    dig = dig + 1
    dp[dig] = {}
    for i = 1, 10 do
      local c = dp[dig - 1][i]
      if i == 1 then
        c = c + dp[dig - 1][10]
      elseif i < 10 then
        c = c + dp[dig - 1][i - 1]
      end
      if i == 10 then
        c = c + dp[dig - 1][1]
      elseif i ~= 9 then
        c = c + dp[dig - 1][i + 1]
      end
      dp[dig][i] = c
    end
    local csum = 0
    for i = 1, 9 do
      csum = csum + dp[dig][i]
    end
    if k <= sum + csum then
      -- found digit
      k = k - sum
      local ret = {}
      for i = 1, 9 do
        if k <= dp[dig][i] then
          table.insert(ret, i)
          break
        else
          k = k - dp[dig][i]
        end
      end
      for idig = dig - 1, 1, -1 do
        local cand = {}
        if 0 < ret[#ret] then
          table.insert(cand, ret[#ret] - 1)
        end
        table.insert(cand, ret[#ret])
        if ret[#ret] < 9 then
          table.insert(cand, ret[#ret] + 1)
        end
        for ic = 1, #cand do
          local i = cand[ic]
          local zi = i
          if i == 0 then i = 10 end
          if k <= dp[idig][i] then
            table.insert(ret, zi)
            break
          else
            k = k - dp[idig][i]
          end
        end
      end
      print(table.concat(ret))
      break
    else
      sum = sum + csum
    end
  end
end
