#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	string S;
	cin >> S;

	string alp = "abcdefghijklmnopqrstuvwxyz";

	if (S.length() < 26) {
		for (int i = 0; i < alp.length(); i++) {
			if (S.find(alp.substr(i, 1)) == string::npos) {
				S += alp.substr(i, 1);
				break;
			}
		}
		cout << S << endl;
	}
	else {
		reverse(S.begin(), S.end());

		if (S == alp) {
			cout << -1 << endl;
		}
		else {
			size_t ii = 0;
			size_t pos = alp.find(S.substr(ii, 1), 0);

			while (pos != string::npos) {
				ii += 1;
				pos = alp.find(S.substr(ii, 1), pos);
			}

			string str = S.substr(ii, 1);

			for (size_t i = 0; i < ii; i++) {
				if (S.substr(i, 1) > str) {
					str = S.substr(i, 1);
					break;
				}
			}

			string ans = str + S.substr(ii + 1);

			reverse(ans.begin(), ans.end());

			cout << ans << endl;
		}
	}

	return 0;
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 3e5 + 10;
const int Mod = 1e9 + 7;
int N;
char S[MAXN];
int To[8][2] = {{3, 1}, {5, 2}, {2, 2}, {4, 7}, {3, 3}, {6, 1}, {5, 5}, {3, 1}};
ll f[MAXN][8];

int main() {
	register int i, j;
	scanf("%s", S + 1); N = strlen(S + 1);
	f[1][0] = 1;
	for(i = 1; i <= N; ++i)
		for(j = 0; j < 8; ++j) {
			if(S[i] != '0') (f[i + 1][To[j][1]] += f[i][j]) %= Mod;
			if(S[i] != '1') (f[i + 1][To[j][0]] += f[i][j]) %= Mod;
		}
	printf("%lld\n", (f[N + 1][1] + f[N + 1][2]) % Mod);
	return 0;
}