def get_b_list(binary_str): b_list = [] s = binary_str.lstrip('0') or '0' # Handle leading zeros if s == '0': return [] while s != '0': reversed_s = s[::-1] b = 0 # Count trailing zeros in the original string (leading zeros in reversed) while b < len(reversed_s) and reversed_s[b] == '0': b += 1 b_list.append(b) # Remove the trailing 'b' zeros and the next 1, then process the remaining part remaining_reversed = reversed_s[b+1:] if not remaining_reversed: new_s = '0' else: new_s = remaining_reversed[::-1].lstrip('0') if not new_s: new_s = '0' s = new_s # Sort the list in descending order b_list.sort(reverse=True) return b_list # Read input n_str = input().strip() m_str = input().strip() # Get the b lists for N and M n_list = get_b_list(n_str) m_list = get_b_list(m_str) # Compare the two lists lexicographically if n_list < m_list: print("Yes") else: print("No")