#include <bits/stdc++.h>
using namespace std;
template <typename tuple<long long int, long long int, long long int> >
void fill_all(tuple<long long int, long long int, long long int> &arr,
              const tuple<long long int, long long int, long long int> &v) {
  arr = v;
}
template <typename tuple<long long int, long long int, long long int>,
          typename ARR>
void fill_all(ARR &arr,
              const tuple<long long int, long long int, long long int> &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
long long int ch[114514], shurui = 0;
string str;
int main() {
  cin >> str;
  if (str.size() == 1) {
    cout << "YES" << endl;
    return 0;
  }
  for (long long int i = (signed)(0); i < (str.size()); ++i) {
    if (ch[str[i] - '0'] == 0) {
      shurui++;
    }
    ch[str[i] - '0']++;
  }
  sort(ch, ch + shurui);
  if (shurui == 2) {
    if (str.size() == 2) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  }
  if (ch[0] == ch[1] && ch[2] <= ch[0]) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}
