Sure. Just initialize a variable, call it count.
Just do:
on *:text:hello world:# {
if (%count = 6) {
msg # hello to you too!
}
else (inc %count)
Something like that. on the 6th time someone says hello world, the bot will answer back with "hello to you too!"