-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path603A.cpp
More file actions
25 lines (17 loc) · 434 Bytes
/
603A.cpp
File metadata and controls
25 lines (17 loc) · 434 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <bits/stdc++.h> // all c++ libraries
// defines
#define faster_io ios_base::sync_with_stdio(false);cin.tie()
#define range(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int N, result = 0;
string str;
int main() {
faster_io;
cin >> N >> str;
range(i, 1, str.size() - 1) {
result += (str[i] == str[i - 1]);
}
result = min(N, N - result + 2);
cout << result;
return 0;
}