With zsh
Assuming you don't care about present directories and you will not have more than 999 files (choose a bigger number if you want, or create a while loop).
[ 6 -le `ls *(.)|wc -l` ] && rm *(.om[6,999])
In *(.om[6,999])
, the .
means files, the o
means sort order up, the m
means by date of modification (put a
for access time or c
for inode change), the [6,999]
chooses a range of file, so doesn't rm the 5 first.