#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <cmath> #include <algorithm> #include <string> #include <iostream> #include <algorithm> #include <string> using namespace std; int convert(string str) { int sum=0; for(int i=0;i<str.length();i++) { sum=sum*10+str[i]-'0'; } return sum; } int main() { string str; cin>>str; int sum=convert(str); if(str.find("0")!=string::npos) { if(sum%3==0) { sort(str.begin(), str.end(), greater<char>()); cout<<convert(str)<<" "; } else cout<<-1<<" "; } else { cout<<-1<<" "; } return 0; }