Your repeat loop contains a series of delay commands, which are pretty much doing exactly what you need—that is to say, they are literally monitoring the amount of time that elapses between the start and end of the command call. We can safely assume that each call to the key code command takes approximately zero seconds, which I imagine is the sole reason you needed the delay command calls to separate them.
There are six calls to delay in each iteration of your repeat loop, each taking 0.4 seconds of time. Therefore, one single iteration takes around 6 × 0.4 = 2.4 seconds.
You want this repeat loop to continue for a total of 300 seconds. This equates to 300 ÷ 2.4 = 125 iterations. Therefore:
tell application "System Events" to repeat 125 times
keystroke "A"
delay 0.4
keystroke "R"
delay 0.4
keystroke "B"
delay 0.4
key code 53
delay 0.4
keystroke "B"
delay 0.4
key code 53
delay 0.4
end repeat
will run for 5 minutes without expending additional time performing extraneous operations or making additional calls, e.g. to current date.