def countOccurrences(s, substr):
count = offset = 0
for i in range(len(s)):
i = s.find(substring, offset)
if (i > 0):
offset = i + len(substring)
count += 1
else:
break
return count;
s = 'java php c c++ python php phphp'
substring = 'php'
print(countOccurrences(s, substring))
'''
run:
3
'''