B - Commencement Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

英小文字からなる文字列 S良い文字列であるとは、すべての 1 以上の整数 i について次の性質が成り立つことであるとします。

  • S にちょうど i 回現れる文字はちょうど 0 種類またはちょうど 2 種類ある

文字列 S が与えられるので、 S が良い文字列か判定してください。

制約

  • S は英小文字からなる長さ 1 以上 100 以下の文字列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S が良い文字列ならば Yes を、そうでないならば No を出力せよ。


入力例 1

commencement

出力例 1

Yes

文字列 commencement にちょうど i 回現れる文字の種類数は以下のとおりです。

  • i=1: o, t2 種類
  • i=2: c, n2 種類
  • i=3: e, m2 種類
  • i\geq 4: 0 種類

よって、commencement は良い文字列の条件を満たします。


入力例 2

banana

出力例 2

No

文字列 banana にちょうど 1 回現れる文字は b1 種類だけであり、良い文字列の条件を満たしません。


入力例 3

ab

出力例 3

Yes

Score: 200 points

Problem Statement

A string S consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers i not less than 1:

  • There are exactly zero or exactly two different letters that appear exactly i times in S.

Given a string S, determine if it is a good string.

Constraints

  • S is a string of lowercase English letters with a length between 1 and 100, inclusive.

Input

The input is given from Standard Input in the following format:

S

Output

Print Yes if S is a good string, and No otherwise.


Sample Input 1

commencement

Sample Output 1

Yes

For the string commencement, the number of different letters that appear exactly i times is as follows:

  • i=1: two letters (o and t)
  • i=2: two letters (c and n)
  • i=3: two letters (e and m)
  • i\geq 4: zero letters

Therefore, commencement satisfies the condition of a good string.


Sample Input 2

banana

Sample Output 2

No

For the string banana, there is only one letter that appears exactly one time, which is b, so it does not satisfy the condition of a good string.


Sample Input 3

ab

Sample Output 3

Yes