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.
import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
	
	
	 public class Palindrome {
	
		static double eps=(double)1e-6;
		static long mod=(int)1e9+7;
		public static void main(String args[]){
			InputReader in = new InputReader(System.in);
			OutputStream outputStream = System.out;
			PrintWriter out = new PrintWriter(outputStream);
			//----------My Code----------
			int n=in.nextInt();
			String h=in.nextLine();
			int count=1;
			char f[]=h.toCharArray();
			char comp=f[0];
			int max=0;
			int len=1;
			for(int i=1;i<f.length;i++){
				if(comp!=f[i]){
					comp=f[i];
					count++;
					max=Math.max(max,len);
					
					len=1;
				}
				else{
					len++;
				}
			}
			max=Math.max(max,len);
			
				count+=2;
			
			System.out.println(Math.min(count,n));
			//---------------The End------------------
			out.close();
		}
		
		
			static class TrieNode{
				boolean isLeaf;
				int b;
				TrieNode[] a=new TrieNode[256];
			}
			
			static void insert(String key,TrieNode root){
				TrieNode temp=root;
				for(int i=0;i<key.length();i++){
				//	System.out.println(i);
					
					if(temp.a[key.charAt(i)]==null){
						temp.a[key.charAt(i)]=new TrieNode();
					}
					temp.a[key.charAt(i)].b+=1;
					temp=temp.a[key.charAt(i)];
					
				}
				temp.isLeaf=true;
			}
			static TrieNode search(String key,TrieNode root){
				TrieNode temp=root;
				for(int i=0;i<key.length();i++){
					
					if(temp.a[key.charAt(i)]==null)
						return null;
					temp=temp.a[key.charAt(i)];
					
				}
				return (temp);
			}
			static String max(String key,TrieNode root){
				TrieNode temp=root;
				String res="";
				for(int i=0;i<key.length();i++){
					
					if(temp.a[(key.charAt(i)-'0')^1]!=null){
					//	System.out.println("Hetr");
					temp=temp.a[(key.charAt(i)-'0')^1];
					res+="1";
					}
					else if(temp.a[(key.charAt(i)-'0')]!=null){
						//System.out.println("Hetr");
						temp=temp.a[(key.charAt(i)-'0')];
						res+="0";
					}
				}
			//	System.out.println(res+"jj");
				return res;
			}
			static void remove(String key,TrieNode root){
				TrieNode temp=root;
				for(int i=0;i<key.length();i++){
					if(temp==null)
						return;
				  if(temp.a[(key.charAt(i)-'0')]!=null&&temp.a[key.charAt(i)-'0'].b>1){
						
						temp.a[(key.charAt(i)-'0')].b--;
						
					
					temp=temp.a[(key.charAt(i)-'0')];
				}
				else
				{
					temp.a[key.charAt(i)-'0']=null;
					return;
				}
				}
				if(temp!=null)
					temp.isLeaf=false;
			}
			
			public static void printSorted(TrieNode node, String s) {
		        for (int ch = 0; ch < node.a.length; ch++) {
		            TrieNode child = node.a[ch];
		            if (child != null){
		                printSorted(child, s + (char)(ch));
		            }
		        }
		        if (node.isLeaf) {
		            System.out.println(s);
		        }
		    }
		private static void permutation(String prefix, String str,HashSet<String> hs) {
		    int n = str.length();
		    if (n == 0) hs.add(prefix);
		    else {
		        for (int i = 0; i < n; i++)
		            permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i+1, n),hs);
		    }
		}
		static int[][] floydWarshall(int graph[][],int V)
	    {
	        int dist[][] = new int[V][V];
	        int i, j, k;
	 
	        /* Initialize the solution matrix same as input graph matrix.
	           Or we can say the initial values of shortest distances
	           are based on shortest paths considering no intermediate
	           vertex. */
	        for (i = 0; i < V; i++)
	            for (j = 0; j < V; j++)
	                dist[i][j] = graph[i][j];
	 
	        /* Add all vertices one by one to the set of intermediate
	           vertices.
	          ---> Before start of a iteration, we have shortest
	               distances between all pairs of vertices such that
	               the shortest distances consider only the vertices in
	               set {0, 1, 2, .. k-1} as intermediate vertices.
	          ----> After the end of a iteration, vertex no. k is added
	                to the set of intermediate vertices and the set
	                becomes {0, 1, 2, .. k} */
	        for (k = 0; k < V; k++)
	        {
	            // Pick all vertices as source one by one
	            for (i = 0; i < V; i++)
	            {
	                // Pick all vertices as destination for the
	                // above picked source
	                for (j = 0; j < V; j++)
	                {
	                    // If vertex k is on the shortest path from
	                    // i to j, then update the value of dist[i][j]
	                    if (dist[i][k] + dist[k][j] < dist[i][j])
	                        dist[i][j] = dist[i][k] + dist[k][j];
	                }
	            }
	        }
	return dist;
	    }
		static int recursiveBinarySearch(int[] sortedArray, int start, int end, int key) {
	
			if (start <= end) {
				int mid = start + (end - start) / 2; 
				if (key < sortedArray[mid]) {
					return recursiveBinarySearch(sortedArray, start, mid-1, key);
	
				} else if (key > sortedArray[mid]) {
					return recursiveBinarySearch(sortedArray, mid+1, end , key);
	
				} else {
					return mid;  
				}
			}
			return -(start + 1); 
		}
	
		static long modulo(long a,long b,long c) {
			long x=1;
			long y=a;
			while(b > 0){
				if(b%2 == 1){
					x=(x*y)%c;
				}
			
				y = (y*y)%c; // squaring the base
				b /= 2;
			}
			return  x%c;
		}
		
		
		static long gcd(long x, long y)
		
		{
			long r=0, a, b;
			a = (x > y) ? x : y; // a is greater number
			b = (x < y) ? x : y; // b is smaller number
			r = b;
			while(a % b != 0)
			{
				r = a % b;
				a = b;
				b = r;
			}
			return r;
		}
		static class pair implements Comparable<pair> {
			int x;
			int y;
			//int i;
			pair(int  xx,int yy){
				
				x=xx;
				y=yy;
				//i=ii;
			}
			@Override
			public int compareTo(pair arg0) {
				return Long.compare(this.y, arg0.y);
			}
		
		}
		static class InputReader {
			public BufferedReader reader;
			public StringTokenizer tokenizer;
	
			public InputReader(InputStream inputstream) {
				reader = new BufferedReader(new InputStreamReader(inputstream));
				tokenizer = null;
			}
	
			public String nextLine(){
				String fullLine=null;
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						fullLine=reader.readLine();
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
					return fullLine;
				}
				return fullLine;
			}
			public String next() {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
				return tokenizer.nextToken();
			}
			public long nextLong() {
				return Long.parseLong(next());
			}
			public int nextInt() {
				return Integer.parseInt(next());
			}
		}
	} 