if __name__ == "__main__": s = input() t = input() print(1 if t * len(s) == s * len(t) else 0)