s=range(10) for n in raw_input():x=[s.pop(int(n))];s=x+s+x print`s`[31::3]