Count how many times a short uppercase pattern N appears as a substring of a longer string H, counting overlapping occurrences.
Easy3StringString matchingBrute forceImplementationInterviewNo attempts yetTime limit1sMemory limit128 MBThe great age of pirates is here. Gyojeong, the captain of the Straw Hat crew, heard one line as a child that he never forgot: the pirate king Gol.D.Sangyun left One Piece, all the treasure he had gathered, out on the Grand Line. Whoever takes One Piece takes the world.
Everyone else shook their head and called it nonsense, but Gyojeong gathered a crew and set out to find One Piece. After passing the sky island and the fish-man island and bringing down the Four Emperors, Gyojeong and his crew found the decisive clue to where One Piece lies. The clue is hard to read at a glance, because it is nothing but uppercase letters run together with no breaks.
Jina, the crew's navigator, sensed at once that some string appears in the clue many times. She cannot tell which string it is, so she decided to start by counting how many times a string she has in mind appears in the whole clue. She believes the string that appears most often points to One Piece.
Jina asks you, the crew's programmer, for help. Write a program that counts how many times the string N she picked appears inside the clue H.
The first line contains the clue string H that the crew obtained. (0<∣H∣≤100000)
The second line contains the string N whose number of occurrences Jina wants to know. (0<∣N∣≤10)
H and N contain no spaces and consist of uppercase letters only.
Print on one line how many times N appears inside H. Occurrences that overlap each other are each counted. If H is AAAA and N is AA, the answer is 3.