Kevin has just recevied his disappointing results on the USA Identification of Cows Olympiad (USAICO) in the form of a binary string of length n. Each character of Kevin's string represents Kevin's score on one of the n questions of the olympiad—'1' for a correctly identified cow and '0' otherwise.

However, all is not lost. Kevin is a big proponent of alternative thinking and believes that his score, instead of being the sum of his points, should be the length of the longest alternating subsequence of his string. Here, we define an alternating subsequence of a string as a not-necessarily contiguous subsequence where no two consecutive elements are equal. For example, {0, 1, 0, 1}, {1, 0, 1}, and {1, 0, 1, 0} are alternating sequences, while {1, 0, 0} and {0, 1, 0, 1, 1} are not.

Kevin, being the sneaky little puffball that he is, is willing to hack into the USAICO databases to improve his score. In order to be subtle, he decides that he will flip exactly one substring—that is, take a contiguous non-empty substring of his score and change all '0's in that substring to '1's and vice versa. After such an operation, Kevin wants to know the length of the longest possible alternating subsequence that his string could have.


-----Input-----

The first line contains the number of questions on the olympiad n (1 ≤ n ≤ 100 000).

The following line contains a binary string of length n representing Kevin's results on the USAICO. 


-----Output-----

Output a single integer, the length of the longest possible alternating subsequence that Kevin can create in his string after flipping a single substring.


-----Examples-----
Input
8
10000011

Output
5

Input
2
01

Output
2



-----Note-----

In the first sample, Kevin can flip the bolded substring '10000011' and turn his string into '10011011', which has an alternating subsequence of length 5: '10011011'.

In the second sample, Kevin can flip the entire string and still have the same score.

Difficulty: competition

Starter code:

Solutions:
x = int(input())
y = input()
if x <= 3:
    print(x)
    quit()

num1 = 0
num0 = 0
for i in y:
    if i == '1':
        num1 = max(num1, num0+1)
    else:
        num0 = max(num0, num1+1)

maxx = max(num1, num0)
if '11' not in y and '00' not in y:
    print(maxx)
    quit()

print(min(maxx+2, x))

n = int(input())
A = list(map(int, ' '.join(input()).split()))
res = 1

for i in range(1, len(A)):
    if A[i] != A[i - 1]:
        res += 1
print(min(res + 2, n))


import sys
def main():
	n = int(input())
	tab = sys.stdin.readline()
	s = 1
	t = tab[0]
	e = 0
	for i in range(1,len(tab)-1):
		if t != tab[i]:
			s+=1
			t = tab[i]
		if tab[i] == tab[i-1] == '0' or tab[i] == tab[i-1] == '1':
			e+=1
			e = min(e,2)
	print(s+e)
main()


s1=int(input())
s2=input()
d=1
et=s2[0]
p=0
tp="2"
for i in range(1,s1):
    if s2[i]!=et:
        d=d+1
        et=s2[i]
    if s2[i]==s2[i-1] and tp!=s2[i]:
        p=p+1
        #tp=s2[i]
    #if s2[i]!=tp:
     #   tp=2
if p==0:
    print(d)
elif p==1:
    print(d+1)
else:
    print(d+2)


input()
a = input()
s = []
for c in a:
 if not s or s[-1][0] != c:
  s.append([c, 1])
 else:
  s[-1][1] += 1
s2 = sorted(s, key=lambda x: x[1])
delta = 0
if s2[-1][1] >= 3 or len(s2) > 1 and s2[-2][1] >= 2:
 delta = 2
elif s2[-1][1] >= 2:
 delta = 1
print(len(s) + delta)

n = int(input())
s = input()
x = 0
y = 1
for i in range (n - 1):
    if s[i] == s[i + 1]:
        x += 1
    if s[i] != s[i + 1]:
        y += 1
print(y + min(2, x))


l, s = int(input()), input()
x, y = 0, 1
for i in range(l-1):
    if s[i] == s[i+1]:
        x += 1
    else: y += 1
print(y + min(2, x))



def main():
    input()
    l, a = [0, 0], '*'
    for b in input():
        l[a == b] += 1
        a = b
    print(l[0] + min(l[1], 2))


def __starting_point():
    main()

__starting_point()

def main():
    n, t, a = int(input()), 0, '*'
    for b in input():
        if a == b:
            t += 1
        else:
            a = b
    print(n - max(t - 2, 0))


def __starting_point():
    main()

__starting_point()

n = int(input())
s = input()
x = 0
y = 1
for i in range (n - 1):
    if s[i] == s[i + 1]:
        x += 1
    if s[i] != s[i + 1]:
        y += 1
print(y + min(2, x))

n = int(input())
a = input()
ans = min(n, 3 + a.count('01') + a.count('10'))

print(ans)


n=int( input() )
s=str( input() )

ret=3
for i in range(1,n):
	if s[i] != s[i-1]:
		ret=ret+1

if ret < n :
	print (ret)
else :
	print (n) 


#! /bin/python
n = int(input())
tab = str(input())

d = 1
tmp = 1
changes = 1
for i in range(1, n):
    if tab[i] != tab[i - 1]:
        changes += 1
print(min(changes + 2, n))



n, tab, changes = int(input()), str(input()), 1
for i in range(1, n):
    changes += 1 if tab[i] != tab[i - 1] else 0
print(min(changes + 2, n))


n = int(input())
s = input().strip()
ret = 1
nb2 = 0
for i in range(1,n):
  if s[i-1] != s[i]:
    ret += 1
  else:
    nb2 += 1
if nb2 >= 2:
  ret += 2
else:
  ret += nb2
print(ret)


n, s = int(input()), input()
print(min(n, s.count("01") + s.count("10") + 3))

n = int(input())
s = input()
cnt = 1
last = s[0]
for i in range(1, len(s)):
  if s[i] != last:
    cnt += 1
    last = s[i]
    
if s.count('111') or s.count('000') or s.count('00')+s.count('11') > 1:
  print(cnt+2)
elif s.count('11')+s.count('00'):
  print(cnt+1)
else:
  print(cnt)

n=int(input())

a=input()

print(min(n,3+a.count('01')+a.count('10')))



# Made By Mostafa_Khaled


n = int(input())
consec= 1
changes = 0
oppo = 0
rep = False
cons = False
s = input().strip()
prev = s[0]
for x in s[1:]:
    if prev != x:
        changes += 1
        consec = 1
        rep = False
    else:
        consec += 1
        if not rep:
            rep = True
            oppo += 1
    if consec == 3:
        cons = True
    prev = x
if cons or oppo > 1:
    changes += 2
elif oppo == 1:
    changes += 1
print(changes+1)


n = int(input())
s = input()
arr = list(map(int, s))
cnt = 0
pcnt = 0
for i in range(n - 1):
    cnt += arr[i] != arr[i + 1]
    pcnt += arr[i] == arr[i + 1]
cnt += min(pcnt, 2)
print(cnt + 1)

n = int(input())
s = input()

dp = [1]*n

for i in range(1,n):
    if s[i]!=s[i-1]:
        dp[i] = max(dp[i], dp[i-1] + 1)
    else:
        dp[i] = dp[i-1]

print(min(n, max(dp)+2))


n = int(input())
s = input()
res = 1

for i in range(0, n - 1):
	if s[i] != s[i + 1]: res += 1
	
print(min(res + 2, n))


n = int(input())
A = list(map(int, ' '.join(input()).split()))
res = 1

for i in range(1, len(A)):
    if A[i] != A[i - 1]:
        res += 1
print(min(res + 2, n))


n = int(input())
s = input()
num = 1
for i in range(1,n):
    if s[i] != s[i-1]:
        num += 1

print(min(n,num+2))


def non_standard(s):
    result = 1
    for i in range(1, len(s)):
        result += (s[i] != s[i - 1])
    return min(result + 2, len(s))


m = int(input())
t = input()
print(non_standard(t))