t="0123456789"while""do a=io.read(1)io.write(t:find(a)-1)t=t:gsub("(.+)("..a..")","%2%1")end