p = input().strip() p_reversed = p[::-1] dp = set() dp.add((0, True, True)) for i in range(len(p_reversed)): current_digit = int(p_reversed[i]) next_dp = set() for state in dp: c_in, a_h, b_h = state a_options = [] if a_h: a_options = [6, 7] else: a_options = [0] b_options = [] if b_h: b_options = [6, 7] else: b_options = [0] for a_i in a_options: for b_i in b_options: sum_ = a_i + b_i + c_in digit_sum = sum_ % 10 carry_out = sum_ // 10 if digit_sum != current_digit: continue a_h_next_options = [] if a_h: a_h_next_options = [True, False] else: a_h_next_options = [False] b_h_next_options = [] if b_h: b_h_next_options = [True, False] else: b_h_next_options = [False] for a_h_next in a_h_next_options: for b_h_next in b_h_next_options: next_state = (carry_out, a_h_next, b_h_next) next_dp.add(next_state) dp = next_dp if not dp: break # Check if any state has carry_out == 0 found = False for state in dp: if state[0] == 0: found = True break print("Yes" if found else "No")