s=gets.chomp c=0 n=s[0] b=8 s.length.times do |i| g=s[i].to_i if g%2==0 b=g if b>g && g!=0 else b=1 end if n!=-1 && n!=g n=-1 end c+=g end if c%9==0 c=9 elsif c%3==0 c=3 else c=1 end if n!=-1 puts s else puts b*c end