191. Exhibition

time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard input
output: standard output



Two companies "A" and "B" decided to hold a joint exhibition of their production. Antitrust committee decided to take an experiment. To have a possibility to show its own production each company must advertise the production of its competitor. The exhibition is built as a straight row of stands. Some stands can be empty, other contain the production of represented companies (each stand can contain the production of only one company). The empty stands are also signed with the names of the companies.
Originally the exhibition consists of just one empty stand, which is signed by the name of one of the companies (by a lot).
The company can choose any of its empty stands and either to fill it with the production of the competitor or to place the empty stand to the left, signed by the name of the competitor, and to the left of that place the stand with its own production. If there are any stands to the left, they are moved to the left. By the beginning of the exhibition all stands must be filled.
Your task is to write a program in accordance with the filled stands before the exhibition to determine if the requirements of the antitrust committee were satisfied or not.

Input
The first line contains the name of the company ("A" or "B"), which was chosen to be the first to fill the empty stand. The second line contains a row of the stands presented to the antitrust committee. The stands are listed from left to right. Letter "A" indicates a stand of company "A", letter "B" - a stand of company "B". Maximum number of stands at the exhibition is 30000.

Output
Output "YES" - if the requirements of the antitrust committee were fulfilled, and "NO" - if not.

Sample test(s)

Input
A
AAB

Output
YES
[submit]
[forum]

Author:Sergey V. Mironov
Resource:ACM International Collegiate Programming Contest 2003-2004
North-Eastern European Region, Southern Subregion
Date:2003 October, 9











Server time: 2017-09-25 22:32:55Online Contester Team © 2002 - 2016. All rights reserved.