#include <bits/stdc++.h>
using namespace std;
int n, tt, dem, max1, dd, ck, max2;
int a[200005], d[5000005];
int b[200005];
char s[100005];
int sol() {
  int i, j, chuan, t1, t2;
  tt = 1;
  dem = 0;
  while (1) {
    ck = 0;
    t1 = 0;
    t2 = 0;
    dem = 1;
    for (i = 0; i < n; i = i + tt) {
      if (ck == 0) {
        ck = 1;
        for (j = i; j < i + tt; j++) {
          t1 = t1 + a[j];
        }
      } else {
        for (j = i; j < i + tt; j++) {
          t2 = t2 + a[j];
        }
        if (t2 < t1) {
          break;
        } else {
          t1 = t2;
          t2 = 0;
          dem++;
        }
      }
    }
    if (i >= n) {
      cout << dem << endl;
      break;
    }
    tt++;
  }
}
int main() {
  int i;
  while (scanf("%d %s", &n, &s) > 0) {
    dem = 3;
    for (i = 1; i < n; i++) {
      if (s[i] != s[i - 1]) dem++;
    }
    cout << min(dem, n) << endl;
  }
  return 0;
}
