#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
typedef long long Int;
int asc(const void *a, const void *b) {
    Int d = *(Int *)a - *(Int *)b;
    return (d > 0) ? 1 : (d < 0) ? -1 : 0;
}

int main() {
    Int n, c, k;
    scanf("%lld %lld %lld", &n, &c, &k);
    Int *T = (Int *)malloc(sizeof(Int) * n);
    rep(i, n) scanf("%lld", T + i);
    qsort(T, n, sizeof(Int), asc);
    bool waiting = false;
    Int start_time = 0;
    Int waiting_people = 0;
    Int ans = 0;
    rep(i, n) {
        Int t = T[i];
        if (waiting) {
            if (t - start_time <= k) {
                waiting_people++;
            } else {
                ans++;
                waiting = true;
                start_time = t;
                waiting_people = 1;
            }
        } else {
            waiting = true;
            start_time = t;
            waiting_people = 1;
        }
        if (waiting_people == c) {
            waiting = false;
            waiting_people = 0;
            ans++;
        }
    }
    if (waiting) {
        ans++;
    }
    printf("%lld\n", ans);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_823/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_823/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 [15 x i8] c"%lld %lld %lld\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.2 = private unnamed_addr constant [6 x i8] c"%lld\0A\00", align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i32 @asc(ptr nocapture noundef readonly %a, ptr nocapture noundef readonly %b) #0 {
entry:
  %0 = load i64, ptr %a, align 8, !tbaa !5
  %1 = load i64, ptr %b, align 8, !tbaa !5
  %cmp = icmp sgt i64 %0, %1
  %cmp1.not = icmp ne i64 %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:
  %n = alloca i64, align 8
  %c = alloca i64, align 8
  %k = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %c) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %k) #6
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %c, ptr noundef nonnull %k)
  %0 = load i64, ptr %n, align 8, !tbaa !5
  %mul = shl i64 %0, 3
  %call1 = call noalias ptr @malloc(i64 noundef %mul) #7
  %conv = trunc i64 %0 to i32
  %cmp45 = icmp sgt i32 %conv, 0
  br i1 %cmp45, label %for.body.preheader, label %for.cond.cleanup

for.body.preheader:                               ; preds = %entry
  %wide.trip.count = and i64 %0, 4294967295
  br label %for.body

for.cond.cleanup.loopexit:                        ; preds = %for.body
  %.pre = load i64, ptr %n, align 8, !tbaa !5
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
  %1 = phi i64 [ %.pre, %for.cond.cleanup.loopexit ], [ %0, %entry ]
  call void @qsort(ptr noundef %call1, i64 noundef %1, i64 noundef 8, ptr noundef nonnull @asc) #6
  %2 = load i64, ptr %n, align 8, !tbaa !5
  %conv6 = trunc i64 %2 to i32
  %cmp847 = icmp sgt i32 %conv6, 0
  br i1 %cmp847, label %for.body11.lr.ph, label %for.cond.cleanup10

for.body11.lr.ph:                                 ; preds = %for.cond.cleanup
  %3 = load i64, ptr %k, align 8
  %4 = load i64, ptr %c, align 8, !tbaa !5
  %wide.trip.count57 = and i64 %2, 4294967295
  br label %for.body11

for.body:                                         ; preds = %for.body.preheader, %for.body
  %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
  %add.ptr = getelementptr inbounds i64, ptr %call1, i64 %indvars.iv
  %call3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef %add.ptr)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body

for.cond.cleanup10.loopexit:                      ; preds = %if.end18
  %5 = and i8 %waiting.2, 1
  %6 = zext i8 %5 to i64
  %7 = add i64 %ans.2, %6
  br label %for.cond.cleanup10

for.cond.cleanup10:                               ; preds = %for.cond.cleanup10.loopexit, %for.cond.cleanup
  %spec.select = phi i64 [ 0, %for.cond.cleanup ], [ %7, %for.cond.cleanup10.loopexit ]
  %call31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %spec.select)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %k) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %c) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #6
  ret i32 0

for.body11:                                       ; preds = %for.body11.lr.ph, %if.end18
  %indvars.iv55 = phi i64 [ 0, %for.body11.lr.ph ], [ %indvars.iv.next56, %if.end18 ]
  %waiting.052 = phi i8 [ 0, %for.body11.lr.ph ], [ %waiting.2, %if.end18 ]
  %ans.050 = phi i64 [ 0, %for.body11.lr.ph ], [ %ans.2, %if.end18 ]
  %waiting_people.049 = phi i64 [ 0, %for.body11.lr.ph ], [ %waiting_people.2, %if.end18 ]
  %start_time.048 = phi i64 [ 0, %for.body11.lr.ph ], [ %start_time.1, %if.end18 ]
  %arrayidx = getelementptr inbounds i64, ptr %call1, i64 %indvars.iv55
  %8 = load i64, ptr %arrayidx, align 8, !tbaa !5
  %9 = and i8 %waiting.052, 1
  %tobool.not = icmp eq i8 %9, 0
  br i1 %tobool.not, label %if.end18, label %if.then

if.then:                                          ; preds = %for.body11
  %sub = sub nsw i64 %8, %start_time.048
  %cmp12.not = icmp sgt i64 %sub, %3
  br i1 %cmp12.not, label %if.else, label %if.then14

if.then14:                                        ; preds = %if.then
  %inc15 = add nsw i64 %waiting_people.049, 1
  br label %if.end18

if.else:                                          ; preds = %if.then
  %inc16 = add nsw i64 %ans.050, 1
  br label %if.end18

if.end18:                                         ; preds = %for.body11, %if.then14, %if.else
  %start_time.1 = phi i64 [ %start_time.048, %if.then14 ], [ %8, %if.else ], [ %8, %for.body11 ]
  %waiting_people.1 = phi i64 [ %inc15, %if.then14 ], [ 1, %if.else ], [ 1, %for.body11 ]
  %ans.1 = phi i64 [ %ans.050, %if.then14 ], [ %inc16, %if.else ], [ %ans.050, %for.body11 ]
  %waiting.1 = phi i8 [ %waiting.052, %if.then14 ], [ 1, %if.else ], [ 1, %for.body11 ]
  %cmp19 = icmp eq i64 %waiting_people.1, %4
  %waiting_people.2 = select i1 %cmp19, i64 0, i64 %waiting_people.1
  %inc22 = zext i1 %cmp19 to i64
  %ans.2 = add nsw i64 %ans.1, %inc22
  %waiting.2 = select i1 %cmp19, i8 0, i8 %waiting.1
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond58.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count57
  br i1 %exitcond58.not, label %for.cond.cleanup10.loopexit, label %for.body11
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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 = { 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
