#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  char s[10000 + 5];
  int len = strlen(s);
  while (scanf("%s", s) != EOF) {
    int countn = 0;
    int flag = 0;
    for (int i = 0; i < len; i++) {
      for (int j = i; j >= 0; i--) {
        if (s[i] == s[j]) {
          countn++;
          if (countn > 2) {
            flag = 1;
            break;
          }
        }
        if (flag == 1) break;
      }
    }
    if (flag == 1)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
