favorite We need a little bit of your help to keep things running, click on this banner to learn more

Programming Principles 1. Week 6. October 7 - 13. PART 2

Data transfering

The data is transmitted from the transmitter to the receiver via a communication channel in the form of a bit sequence. Features of the communication channel are such that during the transmission of a sequence of bits, some distortions may be introduced into it. Thus, the bit sequence t received by the receiver may be different from the s sequence transmitted by the transmitter. One of the types of distortion that can be introduced during the transmission is the so-called transposition of neighboring bits. With this distortion, s and t differ exactly in two adjacent positions i and i + 1, with si = ti+1, si+1 = ti, and for all ji, ji + 1 the equality si = ti is true.

You are one of the researchers dealing with problems of information transfer. Currently you are working on a coding system for an important government communication channel. The code you develop must have the property of correcting one transposition of neighboring bits. In order for the code being developed to be as efficient as possible, you need to obtain information about the reliability level of this channel. Reliability is tested in the following way: the sequence of bits s1, s2, ..., sn is transmitted over the channel, the sequence t1, t2 , ..., tn that was received by the receiver is remembered, and then compared with transmitted. Based on how much of the sequence is transmitted without distortion or with a single transposition, the conclusion is made about the reliability of the channel.

Since the sequence selected for transmission is long enough, it is very laborious to perform their comparison manually. So you decided to write a program that performs this comparison.

Write a program that, according to two given sequences s and t, determines whether it is possible to get t from s by performing at most one transposition of neighboring characters.


First line contains the sequence s, second line contains the sequence t. Both sequences are non-empty, containing only zeros and ones, and have length no more than 105.


If the sequence t can be obtained from the sequence s in the specified way, print YES, otherwise print NO.

Time limit 1 second
Memory limit 128 MiB
Input example #1
Output example #1
Input example #2
Output example #2
Input example #3
Output example #3
Source 2009 Цикл интернет-олимпиад для школьников. First olympiad, base level. September 19, Problem B