#import <stdio.h>
#import <stdlib.h>
int desc(const void *a, const void *b) {
    int d = *(int *)b - *(int *)a;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}
int main() {
    int a[3] = {0};
    char c;
    while ((c = getchar()) != '\n') a[c - 'a']++;
    qsort(a, 3, sizeof(int), desc);
    int total = a[0] + a[1] + a[2];
    switch (total % 3) {
    case 0:
        puts(a[0] == a[1] && a[1] == a[2] ? "YES" : "NO");
        return 0;
    case 1:
        puts(a[0] == a[1] + 1 && a[1] == a[2] ? "YES" : "NO");
        return 0;
    case 2:
        puts(a[0] == a[1] && a[1]  == a[2] + 1? "YES" : "NO");
        return 0;
    }
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_671/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_671/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [4 x i8] c"YES\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"NO\00", align 1
@stdin = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @desc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
  %0 = load i32, ptr %b, align 4, !tbaa !5
  %1 = load i32, ptr %a, align 4, !tbaa !5
  %cmp = icmp sgt i32 %0, %1
  %cmp1.not = icmp ne i32 %0, %1
  %cond = sext i1 %cmp1.not to i32
  %cond2 = select i1 %cmp, i32 1, i32 %cond
  ret i32 %cond2
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #2 {
entry:
  %a = alloca [3 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %a) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %a, i8 0, i64 12, i1 false)
  %0 = load ptr, ptr @stdin, align 8, !tbaa !9
  %call.i47 = tail call i32 @getc(ptr noundef %0)
  %sext48 = shl i32 %call.i47, 24
  %cmp.not49 = icmp eq i32 %sext48, 167772160
  br i1 %cmp.not49, label %while.end, label %while.body

while.body:                                       ; preds = %entry, %while.body
  %sext50 = phi i32 [ %sext, %while.body ], [ %sext48, %entry ]
  %conv1 = ashr exact i32 %sext50, 24
  %sub = add nsw i32 %conv1, -97
  %idxprom = sext i32 %sub to i64
  %arrayidx = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 %idxprom
  %1 = load i32, ptr %arrayidx, align 4, !tbaa !5
  %inc = add nsw i32 %1, 1
  store i32 %inc, ptr %arrayidx, align 4, !tbaa !5
  %2 = load ptr, ptr @stdin, align 8, !tbaa !9
  %call.i = tail call i32 @getc(ptr noundef %2)
  %sext = shl i32 %call.i, 24
  %cmp.not = icmp eq i32 %sext, 167772160
  br i1 %cmp.not, label %while.end, label %while.body

while.end:                                        ; preds = %while.body, %entry
  call void @qsort(ptr noundef nonnull %a, i64 noundef 3, i64 noundef 4, ptr noundef nonnull @desc) #6
  %3 = load i32, ptr %a, align 4, !tbaa !5
  %arrayidx5 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 1
  %4 = load i32, ptr %arrayidx5, align 4
  %add = add nsw i32 %4, %3
  %arrayidx6 = getelementptr inbounds [3 x i32], ptr %a, i64 0, i64 2
  %5 = load i32, ptr %arrayidx6, align 4
  %add7 = add nsw i32 %add, %5
  %rem = srem i32 %add7, 3
  switch i32 %rem, label %cleanup [
    i32 0, label %sw.bb
    i32 1, label %sw.bb17
    i32 2, label %sw.bb31
  ]

sw.bb:                                            ; preds = %while.end
  %cmp10 = icmp eq i32 %3, %4
  %cmp14 = icmp eq i32 %4, %5
  %6 = and i1 %cmp10, %cmp14
  br label %cleanup.sink.split

sw.bb17:                                          ; preds = %while.end
  %add20 = add nsw i32 %4, 1
  %cmp21 = icmp eq i32 %3, %add20
  %cmp26 = icmp eq i32 %4, %5
  %7 = and i1 %cmp21, %cmp26
  br label %cleanup.sink.split

sw.bb31:                                          ; preds = %while.end
  %cmp34 = icmp eq i32 %3, %4
  %add39 = add nsw i32 %5, 1
  %cmp40 = icmp eq i32 %4, %add39
  %8 = select i1 %cmp34, i1 %cmp40, i1 false
  br label %cleanup.sink.split

cleanup.sink.split:                               ; preds = %sw.bb, %sw.bb17, %sw.bb31
  %.sink = phi i1 [ %8, %sw.bb31 ], [ %7, %sw.bb17 ], [ %6, %sw.bb ]
  %cond43 = select i1 %.sink, ptr @.str, ptr @.str.1
  %call44 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %cond43)
  br label %cleanup

cleanup:                                          ; preds = %cleanup.sink.split, %while.end
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %a) #6
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @getc(ptr nocapture noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nofree "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
