# Open the input text file.
f = open('problem001.txt', 'r')
myDictionary = {}
# First line contains the string Text
genome = f.readline().rstrip('\n')
# Second line contains k
k = int(f.readline().rstrip('\n'))
f.close()
# Number of characters in the string
numChars = len(genome)
# Step through the string 1 char at a time and substring out each k characters
for i in range (0, numChars - k + 1):
kmer = genome[i:i+k]
if kmer in myDictionary:
myDictionary[kmer] += 1
else:
myDictionary[kmer] = 1
maxValue = 0
answer = ''
# Sort the keys in the dictionary
for w in sorted(myDictionary, key=myDictionary.get, reverse=True):
if myDictionary[w] >= maxValue:
maxValue = myDictionary[w]
answer += w + ' '
print w, myDictionary[w]
print 'answer'
print answer