#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

int main()
{
	string str;
	cin >> str;
	if (str.size() < 26)
	{
		map<char, ll> mp;
		for (ll i = 0; i < str.size(); i++)
		{
			mp[str[i]]++;
		}
		for (char i = 'a'; i < 'z' + 1; i++)
		{
			if (mp[i] == 0)
			{
				cout << str + i << endl;
				return 0;
			}
		}
	}
	ll index = str.size() - 1;
	for (ll i = str.size() - 1; i > 0 ; i--)
	{
		if (str[i - 1] > str[i])
		{
			index = i - 1;
		}
		else break;
	}
	if (index == 0)
	{
		cout << -1 << endl;
		return 0;
	}
	string q = str.substr(index, 1);
	for (ll i = index; i < str.size(); i++)
	{
		if (str.substr(index - 1, 1) < str.substr(i, 1))
		{
			q = min(q, str.substr(i, 1));
		}
	}
	string ans;
	if (index != 1)
	{
		ans += str.substr(0, index - 1);
	}
	cout << ans + q << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	map<string,int> week;
	week["MON"] = 1; 
		week["TUE"] = 2; 	week["WED"] = 3; 	week["THU"] = 4; 	week["FRI"] = 5; 	week["SAT"] = 6;
			week["SUN"] = 0;  
	string s;
	cin >> s;
	cout << 7 - week[s];
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}
