/*
お題：1のビットが3個ある二進表記文字列が与えられたとき、次に大きい
1のビットが3個ある二進表記文字列を求める。
例
111 -> 1011
1110 -> 10011
101100 -> 110001
*/

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string f623(string s)
{
	const int len = s.length();
	const int c0 = count(s.begin(), s.end(), '0');
	const int c1 = count(s.begin(), s.end(), '1');
	if (s.empty() || s[0] != '1' || c0 + c1 != len) {
		return "INVALID";
	}
	for (int i = len - 1; i > 0; --i) {
		if (s[i - 1] == '0' && s[i] == '1') {
			return s.substr(0, i - 1) + f623(s.substr(i));		
		}
	}
	return '1' + string(c0 + 1, '0') + string(c1 - 1, '1');
}

int main()
{
	for (string s; cin >> s; ) {
		cout << s << " -> " << f623(s) << endl;
	}
}
