Ninjas in a Chat Log Thanks to HyperNeutrino for making more test cases
Often in chat, someone will ask a question, and multiple people will answer it at the same time. Usually, the person who was beaten to the gun will say &quot;ninja'd&quot;, creating even more unnecessary chat.
Given a chat log similar to the following:
Community: Hi
Test: Hi
Rando: What is 4 times 4?
Test: @Rando 16
Community: @Rando 16
Community: ninja'd

You are looking for the number of extraneous lines, which in the above exchange is 2. Two users both replied to another user with the same text, although he only wanted one answer, and then the second user said &quot;ninja'd&quot;.
Extraneous Messages
Note that for the following statement, a message is only the content left of the :&lt;space&gt;. However, if an extraneous message is removed, the &lt;username&gt;:&lt;space&gt; is also removed.
Your only task is finding extraneous messages in the input, and counting them. The first type of extraneous message is a message starting with @ that is basically (spaces and case differences are ignored) the same as the message before it. The second type of extraneous message is a message reading exactly ninja'd (case insensitive) immediately after an extraneous message of the first type by the same user (there will never be users with the same name in different cases, and the same user will always be in the same case).
Input
Your input is the chat log, including the user's names, followed by a colon and a space, followed by their message. You may take the input as a newline-separated string, a list of strings, or another appropriate input format.
Output
Your output is the number of extraneous messages.
Test Cases
Community: Hi
Test: Hi
Rando: What is 4 times 4?
Test: @Rando 16
Community: @Rando 16
Community: NINJA'D

2


A: how is everyone doing today
B: good
C: good
C: this doesn't work: `print5`
A: @C add a space
B: @C add aSpace
B: ninja'd
C: ninja'd

2


A: test
B: @A hi
C: @Ahi
C: ninja'd

2


A: test
B: @A hi
B: @A hi
B: ninja'd

2


A: 
B: @
B: @
B: ninja'd
B: ninja'd

2


A: ninja'd
B: ninja'd
C: @B ninja'd
B: @B ninja'd
B: ninja'd
C: ninja'd
C: ninja'd

2


Test: test
Testie: @Test TESTIE
Test: @Testie TESTIE
Test: ninja'd
Testie: TESTIE
Test: TESTIE

0


A: @B hi
C: @B hi
C: ninja'd
B: @C no
A: @CNO
A: ninja'd

4
Retina, 50 bytes

T`l`L
&#32;

(:@.*)¶(.+)\1
b$2a
b(.*)a¶\1:NINJA'D
aa
a


Try it online!