S = list(input()) M = len(S) answer for i in range(M): if s[i] == 2: answer = answer * 2 else: answer = answer * 2 + 1 print(answer)