#include <iostream>

using namespace std;

inline
int sumDigits(int n) {
    int r = 0;
    while(n) {
        r += n %10;
        n/=10;
    }
    return r;
}

int main() {
    int n;
    char buf[100100];

    while(1) {
        n = 0;
        buf[0] = cin.get();
        if( !isdigit(buf[0])) return 0;
        do {
            n++;
            buf[n] = cin.get();
        } while( buf[n] != '\n' );
        buf[n] = 0;
        int lastlowerable = n-1, firstraisable = -1;
        bool found = false;
        for( int i = n-2; i >= 0; i-- ) {
            if( buf[i] >= '1' ) {
                for( int j = lastlowerable; j > i; j-- ) {
                    if( buf[j] <= '7' ) {
                        firstraisable = j;
                    }
                }
                if( firstraisable != -1 ) {
                    found = true;
                    buf[firstraisable]+=2;
                    buf[i]-=1;
                    if( buf[0] >= '1' )
                        cout << buf << endl;
                    else
                        cout << (buf+1) << endl;
                    break;
                }
            }

        }
        if(!found && buf[0] <= '8' ) {
            buf[0] += 1;
            cout << "-" << (buf) << endl;
        } else {
            cout << "-1" << (buf) << endl;
        }
    }
}