In this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left. 

NOTE: String letters are case-sensitive.

Input Format  

The first line of input contains the original string. The next line contains the substring.

Constraints  

$1\leq len(string)\leq200$ 

Each character in the string is an ascii character. 

Output Format 

Output the integer number indicating the total number of occurrences of the substring in the original string. 

Sample Input

ABCDCDC
CDC

Sample Output

2

Concept

Some string processing examples, such as these, might be useful. 

There are a couple of new concepts: 

In Python, the length of a string is found by the function len(s), where $\boldsymbol{\mathrm{~S~}}$ is the string. 

To traverse through the length of a string, use a for loop:  

for i in range(0, len(s)):
    print (s[i])

A range function is used to loop over some length: 

range (0, 5)

Here, the range loops over $\mbox{o}$ to $\begin{array}{c}A\end{array}$. $5$ is excluded.

Source: hackerrank | Difficulty: EASY
Tags: String algorithms


Solutions:
import sys
if sys.version_info[0] >= 3:
	raw_input = input
s = raw_input().rstrip()
t = raw_input().rstrip()
r = 0
for i in range(len(s) - len(t) + 1):
	if s[i:i + len(t)] == t:
		r += 1
print(r)


s1 = input()
s2 = input()
l = len(s2)
ans = 0
for i in range(len(s1) - l + 1):
	if s1[i:i + l] == s2:
		ans += 1
print(ans)


string = input()
sub = input()
count = 0
for i in range(len(string)):
	if string.find(sub, i, i + len(sub)) >= 0:
		count += 1
print(count)


ip = input()
r = input()
num = 0
x = 0
while ip.find(r, x) != -1:
	x = ip.find(r, x) + 1
	num += 1
print(num)


nStr = str(input())
pattern = str(input())
count = 0
flag = True
start = 0
while flag:
	a = nStr.find(pattern, start)
	if a == -1:
		flag = False
	else:
		count += 1
		start = a + 1
print(count)


st = input()
subst = input()
output = 0
l1 = len(st)
l2 = len(subst)
for i in range(0, l1 - l2 + 1):
	if st[i:i + l2] == subst:
		output = output + 1
print(output)


A = input()
B = input()
LA = len(A)
LB = len(B)
cnt = 0
for i in range(LA - LB + 1):
	if A[i:i + LB] == B:
		cnt += 1
print(cnt)


from sys import stdin

def main():
	big_string = stdin.readline().rstrip()
	sub_string = stdin.readline().rstrip()
	num_matches = 0
	for i in range(len(big_string) - len(sub_string) + 1):
		if big_string[i:i + len(sub_string)] == sub_string:
			num_matches += 1
	print(num_matches)
main()


string = input().strip()
sub = input().strip()
count = 0
for i in range(0, len(string)):
	if string[i:].startswith(sub):
		count += 1
print(count)


big_str = input()
small_str = input()
small_len = len(small_str)
count = 0
for i in range(len(big_str[:-small_len + 1])):
	if big_str[i:i + small_len] == small_str:
		count += 1
print(count)


string = input()
subString = input()
count = 0
for i in range(len(string) - len(subString) + 1):
	curSubString = string[i:i + len(subString)]
	if curSubString == subString:
		count += 1
print(count)


str = input()
substr = input()
l = len(str)
i = 0
templen = len(substr)
tpl = templen
count = 0
while i < l - tpl + 1:
	st = str[i:templen]
	i += 1
	templen += 1
	if st == substr:
		count += 1
print(count)


a = input()
b = input()
a1 = len(a)
b1 = len(b)
k = 0
for i in range(a1 + 1 - b1):
	if b == a[i:i + b1]:
		k += 1
print(k)


haystack = input()
needle = input()
cnt = 0
for i in range(len(haystack) - len(needle) + 1):
	if haystack.find(needle, i) == i:
		cnt += 1
print(cnt)


s = input()
t = input()
ans = 0
for i in range(len(s) - len(t) + 1):
	if s[i:i + len(t)] == t:
		ans += 1
print(ans)


a = input()
b = input()
c = 0
for i in range(len(a) - len(b) + 1):
	if a[i:len(b) + i] == b:
		c += 1
print(c)


full = input()
find = input()
fl = len(full)
ffl = len(find)
ans = 0
for c in range(fl):
	flag = 0
	if find[0] == full[c]:
		flag = flag + 1
		for x in range(1, ffl):
			if c + x < fl and find[x] == full[c + x]:
				flag = flag + 1
			else:
				break
		if flag == ffl:
			ans = ans + 1
print(ans)


string = input()
sub = input()
count = 0
for i in range(0, len(string) - len(sub) + 1):
	if string[i:i + len(sub)] == sub:
		count += 1
print(count)


s = input()
c = input()
k = 0
for i in range(0, len(s) - len(c) + 1):
	if c == s[i:i + len(c)]:
		k += 1
print(k)


s = input()
s1 = input()
j = 0
for i in range(0, len(s)):
	if s[i] == s1[0]:
		t = i
		f = 0
		for k in s1:
			if s[t] == k:
				f += 1
				t += 1
			else:
				break
			if t >= len(s):
				break
		if f == len(s1):
			j += 1
print(j)


s = input().strip()
sub = input().strip()
n = 0
idx = 0
while True:
	try:
		idx = s.index(sub, idx)
	except ValueError:
		break
	if idx == -1:
		break
	n += 1
	idx += 1
print(n)


a = input()
b = input()
print(sum((int(a[i:i + len(b)] == b) for i in range(len(a)))))


s = input()
ss = input()
count = 0
for i in range(len(s) - len(ss) + 1):
	if s[i:i + len(ss)] == ss:
		count += 1
print(count)


mainstr = input()
substr = input()
count = 0
i = 0
while i < len(mainstr):
	if mainstr.find(substr, i, len(mainstr)) >= 0:
		count += 1
		i = mainstr.find(substr, i, len(mainstr))
		i += 1
	else:
		break
print(count)


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
if l2 > 0 and l1 >= l2:
	SS = [s1[i:i + l2] for i in range(0, l1 - l2 + 1)]
	print(SS.count(s2))


def main():
	string = str(input())
	sub = str(input())
	c = 0
	for i in range(len(string) - len(sub) + 1):
		c += sub == string[i:i + len(sub)]
	print(c)
main()


a = input()
b = input()

def KMP(string, sub):
	count = 0
	sub = list(sub)
	s = [1] * (len(sub) + 1)
	shift = 1
	for i in range(len(sub)):
		while shift <= i and sub[i] != sub[i - shift]:
			shift += s[i - shift]
		s[i + 1] = shift
	start = 0
	matchLen = 0
	for c in string:
		while matchLen == len(sub) or (matchLen >= 0 and sub[matchLen] != c):
			start += s[matchLen]
			matchLen -= s[matchLen]
		matchLen += 1
		if matchLen == len(sub):
			count = count + 1
	print(count)
KMP(a, b)


st = ''
st = input()
ss = input()
ln = len(ss)
cnt = 0
for i in range(0, len(st)):
	s = st[i:i + ln]
	if s == ss:
		cnt += 1
print(cnt)


def countSubstrings(s, sub):
	return sum((s[start:start + len(sub)] == sub for start in range(len(s))))
print(countSubstrings(input(), input()))


str1 = input()
str2 = input()

def strmatch(s1, s2):
	k = s1.find(s2)
	if k == -1:
		return 0
	else:
		return 1 + strmatch(s1[k + 1:], s2)
print(strmatch(str1, str2))


def countoverlap(string, substring):
	count = 0
	for i in range(len(string)):
		if string[i:].startswith(substring):
			count = count + 1
	return count
string = input()
substring = input()
print(countoverlap(string, substring))


string = input()
substring = input()
sums = 0
for i in range(0, len(string)):
	if string.find(substring, i, i + len(substring)) != -1:
		sums = sums + 1
print(sums)


s_long = input()
s_short = input()
short_len = len(s_short)
num_occur = 0
for i in range(len(s_long) - short_len + 1):
	s_test = s_long[i:i + short_len]
	if s_test == s_short:
		num_occur += 1
print(num_occur)


(s, t) = (input(), input())
print(sum((int(s.startswith(t, i)) for i in range(len(s)))))


s = input()
sub = input()
l = [i for i in range(len(s)) if s.startswith(sub, i)]
print(len(l))


stng = input()
s = input()
count = 0
while len(stng) != 0:
	i = 0
	while i < len(stng) and stng[i] == s[i]:
		i += 1
		if i == len(s):
			count += 1
			break
	stng = stng[1:]
print(count)


def count_substring(string, sub_string):
	res = 0
	len_sub = len(sub_string)
	for i in range(len(string) - len_sub + 1):
		if string[i:i + len_sub] == sub_string:
			res += 1
		i += 1
	return res


a = input()
b = input()
l = len(b)
cnt = 0
p = 0
while True:
	p = a.find(b, p)
	if p == -1:
		break
	p += 1
	cnt += 1
print(cnt)


A = input()
B = input()
print(len([i for i in range(len(A)) if A.startswith(B, i)]))


def main():
	string = input()
	substr = input()
	strlen = len(string)
	substrlen = len(substr)
	occ = 0
	for i in range(strlen - substrlen + 1):
		if string[i:i + substrlen] == substr:
			occ += 1
	print(occ)
main()


s = input()
ss = input()
n = 0
idx = 0
pos = s.find(ss)
while pos != -1:
	n += 1
	idx += pos + 1
	pos = s[idx:].find(ss)
print(n)


s = input()
ss = input()
cnt = 0
len_s = len(s)
len_ss = len(ss)
for i in range(0, len_s):
	tmp = s[i:i + len_ss]
	if tmp == ss:
		cnt = cnt + 1
print(cnt)


first = input()
second = input()
print(sum([1 if first[i:i + len(second)] == second else 0 for i in range(len(first))]))


string = input()
pattern = input()
count = 0
pos = string.find(pattern, 0)
while pos != -1:
	pos = string.find(pattern, pos + 1)
	count += 1
print(count)


str = input()
sub = input()
i = 0
j = 0
k = 0
count = 0
len1 = len(str)
len2 = len(sub)
while i < len1:
	k = 0
	j = 0
	while j < len2 and i + j < len1:
		if str[i + j] == sub[j]:
			k = k + 1
			if k == len2:
				count += 1
				break
			j += 1
		else:
			break
	i += 1
print(count)


a = input()
b = input()
c = 0
for i in range(len(a) - len(b) + 1):
	s = 0
	for j in range(len(b)):
		if a[i + j] != b[j]:
			s = 1
			break
	if s == 0:
		c += 1
print(c)


strA = input()
search = input()
c = 0
for x in range(len(strA) - len(search) + 1):
	if strA[x:x + len(search)] == search:
		c += 1
print(c)


target = input()
subString = input()
lastPos = 0
count = 0
while True:
	lastPos = target.find(subString, lastPos)
	if lastPos == -1:
		break
	count += 1
	lastPos += 1
print(count)


import re
string1 = input()
pat = input()
count = 0
for i in range(0, len(string1)):
	if string1[i:i + len(pat)] == pat:
		count += 1
print(count)


text = input()
sub = input()
print(len([index for (index, _) in enumerate(text) if text.startswith(sub, index)]))


import re

def occurrences(text, sub):
	return len(re.findall('(?={0})'.format(re.escape(sub)), text))
s = input()
t = input()
print(occurrences(s, t))


s1 = input()
s2 = input()
cnt = 0
for start in range(len(s1)):
	if s1.startswith(s2, start):
		cnt += 1
print(cnt)


import re

def count(subs, s):
	return sum((s[i:].startswith(subs) for i in range(len(s))))
s = input()
sub = input()
print(count(sub, s))


s = input()
d = input()
f = 1
ans = 0
l = len(s)
for i in range(0, l):
	if s[i] == d[0] and i + len(d) <= l:
		for j in range(0, len(d)):
			if s[i + j] != d[j]:
				break
			if j == len(d) - 1:
				ans += 1
print(ans)


s = input()
subs = input()
print(len([i for i in range(len(s)) if s.startswith(subs, i)]))


n = input()
m = input()
cnt = 0
for i in range(len(n) - len(m) + 1):
	if n[i:i + len(m)] == m:
		cnt += 1
print(cnt)


def occurrences(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count
a = input()
b = input()
print(occurrences(a, b))


from sys import stdin

def main():
	string = stdin.readline()
	sub_str = stdin.readline()
	sub_len = len(sub_str)
	count = 0
	for i in range(0, len(string) - len(sub_str) + 1):
		curr_sub = string[i:i + sub_len]
		if curr_sub == sub_str:
			count += 1
	print(count)
main()


s = input()
tests = input()
n = len(s)
nt = len(tests)
count = 0
for i in range(n - nt + 1):
	if s[i] == tests[0]:
		if s[i:i + nt] == tests:
			count += 1
print(count)


S = str(input())
L = len(S)
s = str(input())
l = len(s)
c = 0
for i in range(L - l + 1):
	if s == S[i:i + l]:
		c += 1
print(c)


s1 = input()
s2 = input()
ls = len(s2) - 1
ct = 0
for i in range(len(s1) - ls):
	if s1[i:i + ls + 1] == s2:
		ct += 1
print(ct)


string = input()
substring = input()
total = 0
start = 0
while start < len(string) and substring in string[start:]:
	total += 1
	start += string[start:].index(substring) + 1
print(total)


str = input()
pattern = input()
count = 0
if len(str) >= 1 and len(str) <= 200:
	for i in range(0, len(str) - len(pattern) + 1):
		k = i
		flag = 1
		for j in range(0, len(pattern)):
			if pattern[j] == str[k]:
				j += 1
				k += 1
			else:
				flag = 0
				break
		if flag != 0:
			count += 1
print(count)


s1 = input()
s1 = s1.rstrip()
s2 = input()
s2 = s2.rstrip()
count = 0
for i in range(0, len(s1)):
	if s2 == s1[i:i + len(s2)]:
		count = count + 1
print(count)


string = input()
substring = input()
count = 0
for i in range(0, len(string) - len(substring) + 1):
	for x in range(len(substring)):
		if substring[x] != string[i]:
			break
		if x == len(substring) - 1:
			count = count + 1
		if substring[x] == string[i]:
			i = i + 1
			continue
print(count)


(str, substr) = (input(), input())
count = 0
for i in range(len(str) - len(substr) + 1):
	if str[i:i + len(substr)] == substr:
		count += 1
print(count)


str1 = input()
str2 = input()
count = 0
for i in range(0, len(str1)):
	if str2 in str1[i:len(str2) + i]:
		count += 1
print(count)


S = input()
T = input()
t = len(T)
ans = 0
for i in range(len(S)):
	if S[i:i + t] == T:
		ans += 1
print(ans)


count = 0
a = input()
b = input()
for i in range(len(a)):
	if a[i:i + len(b)] == b:
		count += 1
print(count)


s = input()
t = input()
count = 0
for i in range(0, len(s)):
	flag = 0
	for j in range(0, len(t)):
		if i + j >= len(s) or s[i + j] != t[j]:
			flag = 1
			break
	if flag == 0:
		count += 1
print(count)


s = str(input())
t = str(input())
ans = 0
for i in range(0, len(s) - len(t) + 1):
	if s[i:i + len(t)] == t:
		ans = ans + 1
print(ans)


a = input()
b = input()
count = 0
for i in range(0, len(a)):
	if b == a[i:i + len(b)]:
		count += 1
print(count)


u = input()
v = input()
occs = 0
i = 0
while i < len(u):
	occ = u.find(v, i)
	if occ == -1:
		break
	else:
		occs += 1
		i = occ + 1
print(occs)


s = input().strip()
sub = input().strip()
cur_len = len(sub)
ans = 0
for i in range(len(s)):
	if s[i] == sub[0]:
		if s[i:i + cur_len] == sub:
			ans += 1
print(ans)


s = input()
t = input()
l1 = len(s)
l2 = len(t)
c = 0
for i in range(0, l1):
	u = s[i:i + l2]
	if u == t:
		c += 1
print(c)


line = input()
sub = input()
l_len = len(line)
s_len = len(sub)
count = 0
for i in range(l_len):
	if line[i:i + s_len] == sub:
		count += 1
print(count)


string = input()
s = input()
print(sum([1 for i in range(len(string) - len(s) + 1) if string[i:i + len(s)] == s]))


import sys

def freopen(f, option, stream):
	import os
	oldf = open(f, option)
	oldfd = oldf.fileno()
	newfd = stream.fileno()
	os.close(newfd)
	os.dup2(oldfd, newfd)
n = input()
m = input()
nlen = len(n)
mlen = len(m)
ans = 0
for i in range(nlen):
	l = i
	same = 0
	for j in range(mlen):
		if l >= nlen:
			break
		if n[l] == m[j]:
			same += 1
		else:
			break
		l += 1
	if same == mlen:
		ans += 1
print(ans)


a = input()
b = input()
c = 0
for i in range(len(a) - len(b) + 1):
	if a[i:i + len(b)] == b:
		c = c + 1
print(c)


string = input()
substring = input()
count = 0
x = len(substring)
for i in range(len(string) - len(substring) + 1):
	if string[i:i + x] == substring:
		count += 1
print(count)


x = input()
y = input()
n = 0
while 1:
	try:
		k = x.index(y)
	except:
		k = len(x)
		break
	x = x[k + 1:]
	n += 1
print(n)


import sys

def main():
	inp = sys.stdin
	mystr = inp.readline().rstrip()
	substr = inp.readline().rstrip()
	(a, b, c) = mystr.partition(substr)
	lc = substr[-1:]
	substrCount = 0
	while not len(b) == 0:
		substrCount += 1
		c = lc + c
		(a, b, c) = c.partition(substr)
	print(substrCount)
main()


org = input()
s_str = input()
c = 0
i = 0
for _ in range(len(org)):
	loc = org.find(s_str, i, len(org))
	if loc != -1:
		c += 1
		i = loc + 1
print(c)


a = input()
b = input()
result = 0
for i in range(len(a)):
	if a[i:i + len(b)] == b:
		result += 1
print(result)


main_string = input()
sub_string = input()
count = 0
for i in range(0, len(main_string)):
	if main_string[i:i + len(sub_string)] == sub_string:
		count += 1
print(count)


s = input()
s1 = input()
a = 0
while s:
	if s1 in s:
		i = s.index(s1)
		s = s[i + 1:]
		a += 1
	else:
		break
print(a)


word = input()
needle = input()
counter = 0
for i in range(len(word) - len(needle) + 1):
	if word[i:i + len(needle)] == needle:
		counter += 1
print(str(counter))


sparent = input()
schild = input()
count = 0
ind = 0
while 2 > 1:
	ind = sparent.find(schild, ind)
	if ind > -1:
		count += 1
		ind += 1
	else:
		break
print(count)


s1 = input()
s2 = input()
print(sum((1 for i in range(len(s1)) if s2 == s1[i:i + len(s2)])))


S = input()
ss = input()
count = 0
for i in range(0, len(S)):
	count += S.count(ss, i, i + len(ss))
print(count)


s = input()
ss = input()
c = 0
for i in range(len(s) - len(ss) + 1):
	x = True
	for j in range(len(ss)):
		if s[i + j] != ss[j]:
			x = False
	if x:
		c += 1
print(c)


from re import findall
s1 = input()
s2 = input()
n = len(findall('(?=' + s2 + ')', s1))
print(n)


source = input()
sub = input()
result = 0
i = 0
for i in range(0, len(source) - len(sub) + 1):
	if source[i:i + len(sub)] == sub:
		result += 1
	i += 1
print(result)


def main():
	s1 = input()
	s2 = input()
	l1 = len(s1)
	l2 = len(s2)
	a = 0
	b = l2
	count = 0
	while b <= l1:
		if s2 == s1[a:b]:
			count = count + 1
		a = a + 1
		b = b + 1
	print(count)
main()


s = input()
subs = input()
res = 0
for i in range(len(s) - len(subs) + 1):
	if s[i:i + len(subs)] == subs:
		res += 1
print(res)


def my_count(string, substring):
	string_size = len(string)
	substring_size = len(substring)
	count = 0
	for i in range(0, string_size - substring_size + 1):
		if string[i:i + substring_size] == substring:
			count += 1
	return count
string = input()
substring = input()
print(my_count(string, substring))


string = input()
sub = input()
count = 0
for i in range(len(string) - len(sub) + 1):
	thingy = True
	for j in range(len(sub)):
		if string[i + j] != sub[j]:
			thingy = False
			break
	if thingy:
		count += 1
print(count)