from collections import Counter
def find_needle(n,h):
c = Counter()
c.update(h.split())
return c[n]
n = "portugal"
h = 'lobito programmer from portugal hello fromportugal portugal'''
print find_needle(n,h)
ZnJvbSBjb2xsZWN0aW9ucyBpbXBvcnQgQ291bnRlcgoKZGVmIGZpbmRfbmVlZGxlKG4saCk6CiAgICBjID0gQ291bnRlcigpCiAgICBjLnVwZGF0ZShoLnNwbGl0KCkpCiAgICByZXR1cm4gY1tuXQoKbiA9ICJwb3J0dWdhbCIKaCA9ICdsb2JpdG8gcHJvZ3JhbW1lciBmcm9tIHBvcnR1Z2FsIGhlbGxvIGZyb21wb3J0dWdhbCBwb3J0dWdhbCcnJwoKcHJpbnQgZmluZF9uZWVkbGUobixoKQ==