#include int main(){ int x, max; scanf("%d", &x); if(x<0) x*=-1; if(x<1000 || x>9999){ printf("-1\n"); return 1; } max = x%10; if((x/10)%10>max) max = (x/10)%10; if((x/100)%10>max) max = (x/100)%10; if((x/1000)%10>max) max = (x/1000)%10; printf("%d\n",max); return 0; }