local s = io.read() local t = {} t[0] = {} t[0][0] = true local row, col = 0, 0 local top, left, right = 1, 2, 3 local bottom = 0 local ret = 1 local function register() if not t[row] then t[row] = {} end if not t[row][col] then ret = ret + 1 end t[row][col] = true end for i = 1, #s do local b = s:byte(i) - 96 if i % 2 == 1 then if top == b then bottom = top row = row - 1 elseif left == b then left, right, bottom = top, left, right col = col - 1 else--if right == b then left, right, bottom = right, top, left col = col + 1 end else if bottom == b then top = bottom row = row + 1 elseif left == b then left, right, top = bottom, left, right col = col - 1 else--if right == b then left, right, top = right, bottom, left col = col + 1 end end register() end print(ret)