Source Code
#include <iostream>
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	if(s[0] == s[n - 1]){
		cout << n - 1;
	}
	else{
		cout << n - 2;
	}
	return 0;
}
Copy
Pop Pop azoz
GNU G++17
1 ms
868 KB
Accepted