#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s, t;
    cin >> s >> t;

    if(s == "Y") transform(t.begin(), t.end(), t.begin(), ::toupper);
    cout << t << "\n";

    return 0;
}
#include<iostream>
#include<vector>
#include<chrono>
#include<iomanip>
#include<set>
#include<algorithm>
#include<bitset>

#define int long long
#define fi first
#define se second

using namespace std;

const int MAXN = 205;
const int MOD = 1e9 + 7;
//const int INF = 1e18;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base :: sync_with_stdio(0);
    int n;
    string s;
    cin >> n >> s;
    if (s[0] != s.back()) {
        cout << 1;
        return 0;
    }
    for (int i = 1; i < n - 2; i++) {
        if (s[i] != s[0] && s[i + 1] != s[0]) {
            cout << 2;
            return 0;
        }
    }
    cout << -1;
    return 0;
}
