def checkams(x,l):
    amstrong=0    
    for i in x:
        amstrong+=int(i)**l
    if(amstrong==int(x)):
        return True
    else:
        return False
        
s=input()
out=''
d={}
for i in s:
    try:
        d[i]+=1
    except:
        d[i]=1
sum=0        
for i in s:
    sum+=ord(i)
l=len(str(sum))
if checkams(str(sum),l):
    out=''.join([i for i in d.keys()])
    print(out)
else:
    print("-1")

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: