s=eval(input())

t="abcdefghijklmnopqrstuvwxyz"

if s==t[::-1]:print((-1));exit()

if len(s)<26:

  for i in t:

    if not i in s:print((s+i));exit()

else:

  for i in range(25):

    if s[-i-2]<s[-1-i]:

      t=s[:-i-2]

      a=sorted(list(s[-2-i:]))

      print((t+a[a.index(s[-2-i])+1]));exit()
t="abcdefghijklmnopqrstuvwxyz"

s=eval(input())

if s==t[::-1]:print((-1));exit()

if len(s)!=26:

  for i in t:

    if i not in s:print((s+i));exit()

i=25

while s[i-1]>s[i]:i-=1

tt=s[i-1]

ss=list(s[i-1:])

ss.sort()

print((s[:i-1]+ss[ss.index(tt)+1]))
s = eval(input())
t = "abcdefghijklmnopqrstuvwxyz"
if s == t[::-1]:
    print((-1))
    exit()
if len(s) < 26:
    for i in t:
        if not i in s:
            print((s + i))
            exit()
else:
    for i in range(25):
        if s[-i - 2] < s[-1 - i]:
            t = s[: -i - 2]
            a = sorted(list(s[-2 - i :]))
            print((t + a[a.index(s[-2 - i]) + 1]))
            exit()

t = "abcdefghijklmnopqrstuvwxyz"
s = eval(input())
if s == t[::-1]:
    print((-1))
    exit()
if len(s) != 26:
    for i in t:
        if i not in s:
            print((s + i))
            exit()
i = 25
while s[i - 1] > s[i]:
    i -= 1
tt = s[i - 1]
ss = list(s[i - 1 :])
ss.sort()
print((s[: i - 1] + ss[ss.index(tt) + 1]))

+t = "abcdefghijklmnopqrstuvwxyz" -t = "abcdefghijklmnopqrstuvwxyz" -if len(s) < 26: +if len(s) != 26: -        if not i in s: +        if i not in s: -else: -    for i in range(25): -        if s[-i - 2] < s[-1 - i]: -            t = s[: -i - 2] -            a = sorted(list(s[-2 - i :])) -            print((t + a[a.index(s[-2 - i]) + 1])) -            exit() +i = 25 +while s[i - 1] > s[i]: +    i -= 1 +tt = s[i - 1] +ss = list(s[i - 1 :]) +ss.sort() +print((s[: i - 1] + ss[ss.index(tt) + 1]))