import sys
import hashlib as hashl
f1 = open("doc1.txt", "r+", encoding = 'utf-8')
f2 = open("doc2.txt", "r+", encoding = 'utf-8')
L = str(f1.read())
M = str(f2.read())
Listofhashes = []
for i in range(10):
#hd1 = hashl.md5(L)
    hd1 = hashl.md5(L.encode('utf-8'))
    s = str(hd1.hexdigest())[:2]
    Listofhashes.append(s)
    L = L + " "
d = 0
print(Listofhashes)
while True:
    d+=1
    hd2 = hashl.md5(M.encode('utf-8'))
    z= str( hd2.hexdigest())[:2]
    print(z)
    if z in Listofhashes:
        print(d)
        break
    M = M + " "