import collections
s = input()
maxLetters = int(input())
minSize = int(input())
maxSize = int(input())
result = next((i for x, i in collections.Counter(s[i - minSize:i] for i in
    range(minSize, len(s) + 1)).most_common() if len(set(x)) <= maxLetters), 0)
print(result)

189511e4d421eaca4a535178fa14c63b89135cda
<mask token>

<mask token>
print(result)

<mask token>
s = input()
maxLetters = int(input())
minSize = int(input())
maxSize = int(input())
result = next((i for x, i in collections.Counter(s[i - minSize:i] for i in
    range(minSize, len(s) + 1)).most_common() if len(set(x)) <= maxLetters), 0)
print(result)

import collections
s = input()
maxLetters = int(input())
minSize = int(input())
maxSize = int(input())
result = next((i for x, i in collections.Counter(s[i - minSize:i] for i in
    range(minSize, len(s) + 1)).most_common() if len(set(x)) <= maxLetters), 0)
print(result)
