s=open(0).read().replace("\n","") print("YNeos"[(len(set(s[0::2]))*len(set(s[1::2]))!=1or len(set(s))!=2)::2])