def decompose(s): if s == '0': return ('0', 0) i = len(s) - 1 while i >= 0 and s[i] == '0': i -= 1 b = len(s) - 1 - i s_trimmed = s[:i+1] if len(s_trimmed) == 1 and s_trimmed[0] == '1': s_minus_1 = '0' else: s_minus_1 = s_trimmed[:-1] + '0' if s_minus_1 == '0': a_str = '0' else: a_str = s_minus_1[:-1] if len(s_minus_1) > 1 else '0' return (a_str, b) def is_less_iter(n_str, m_str): stack = [] stack.append((n_str, m_str, False)) result = None while stack and result is None: current_n, current_m, compare_a = stack.pop() if compare_a: stack.append((current_n, current_m, False)) else: if current_n == '0': if current_m == '0': continue else: result = True break if current_m == '0': result = False break a_n, b_n = decompose(current_n) a_m, b_m = decompose(current_m) b_n_str = bin(b_n)[2:] if b_n != 0 else '0' b_m_str = bin(b_m)[2:] if b_m != 0 else '0' stack.append((a_n, a_m, True)) stack.append((b_n_str, b_m_str, False)) return result if result is not None else False n = input().strip() m = input().strip() if n == '0' and m == '0': print("No") else: print("Yes" if is_less_iter(n, m) else "No")