a = input()[1:-1].split(',')
b = []
c = []
for i in range(len(a)):
    b.append(int(a[i]))
b.sort()
d = int(input())
for i in range(len(b)):
    for j in range(i+1,len(b)-1):
        c.append(b[j]-b[i])
        if( len(c)==d ):
            print(c[d-1])
            break
    if (len(c) == d):
        break
f2fdc2c3f3b30f8917921c9dc058dd6baee87302
<mask token>

<mask token>
for i in range(len(a)):
    b.append(int(a[i]))
b.sort()
<mask token>
for i in range(len(b)):
    for j in range(i + 1, len(b) - 1):
        c.append(b[j] - b[i])
        if len(c) == d:
            print(c[d - 1])
            break
    if len(c) == d:
        break

a = input()[1:-1].split(',')
b = []
c = []
for i in range(len(a)):
    b.append(int(a[i]))
b.sort()
d = int(input())
for i in range(len(b)):
    for j in range(i + 1, len(b) - 1):
        c.append(b[j] - b[i])
        if len(c) == d:
            print(c[d - 1])
            break
    if len(c) == d:
        break

a = input()[1:-1].split(',')
b = []
c = []
for i in range(len(a)):
    b.append(int(a[i]))
b.sort()
d = int(input())
for i in range(len(b)):
    for j in range(i+1,len(b)-1):
        c.append(b[j]-b[i])
        if( len(c)==d ):
            print(c[d-1])
            break
    if (len(c) == d):
        break