UK and US: Part 2

  • + 0 comments
    import re
    
    
    txt = ""
    for i in range(int(input())):
        txt +=" "+input()
    
    
    for j in range(int(input())):
        
        word = input()
        i = word.index("our")
        w1,w2  = word[:i+1],word[i+2:]
        
        print(len(re.findall(fr'\b{w1}u?{w2}\b',txt)))