import re
#for i, j in enumerate(s):
s = list([int(n) for n in re.findall(r"\-?\d+", input())])
s.sort()
f = [False]*100
for i in s:
    if i >= 0:
        f[i] = True
ans = 0
for i in f:
    if not i:
        if ans != 0:
            print(ans)
            break
    ans += 1
fff96309d6f9ea8a3a5ca4a5dc2491ef76f9e7ef
<mask token>

<mask token>
s.sort()
<mask token>
for i in s:
    if i >= 0:
        f[i] = True
<mask token>
for i in f:
    if not i:
        if ans != 0:
            print(ans)
            break
    ans += 1

<mask token>
s = list([int(n) for n in re.findall('\\-?\\d+', input())])
s.sort()
f = [False] * 100
for i in s:
    if i >= 0:
        f[i] = True
ans = 0
for i in f:
    if not i:
        if ans != 0:
            print(ans)
            break
    ans += 1

import re
s = list([int(n) for n in re.findall('\\-?\\d+', input())])
s.sort()
f = [False] * 100
for i in s:
    if i >= 0:
        f[i] = True
ans = 0
for i in f:
    if not i:
        if ans != 0:
            print(ans)
            break
    ans += 1

import re
#for i, j in enumerate(s):
s = list([int(n) for n in re.findall(r"\-?\d+", input())])
s.sort()
f = [False]*100
for i in s:
    if i >= 0:
        f[i] = True
ans = 0
for i in f:
    if not i:
        if ans != 0:
            print(ans)
            break
    ans += 1