while 1:print int(''.join(`d-d/5`for d in map(int,`input()`)),8)