public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new File("beads.in"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("beads.out")));

        int N = in.nextInt();
        in.nextLine();
        String necklace = in.next();
        // copy the necklace, trans the circle to line
        String strBeads = String.format("%s%s", necklace, necklace);
        char[] beads = strBeads.toCharArray();

        //before: 0 to this-1
        int[] befBlue = new int[beads.length];
        int[] befRed = new int[beads.length];
        befBlue[0] = befRed[0] = 0;
        for (int i = 1; i < beads.length; i++) {
            if (beads[i - 1] == 'b') {
                befBlue[i] = befBlue[i - 1] + 1;
                befRed[i] = 0;
            } else if (beads[i - 1] == 'r') {
                befBlue[i] = 0;
                befRed[i] = befRed[i - 1] + 1;
            } else {
                // beads[i-1] == 'w'
                befBlue[i] = befBlue[i - 1] + 1;
                befRed[i] = befRed[i - 1] + 1;
            }
        }

        //after: this to end
        int[] aftBlue = new int[beads.length + 1];
        int[] aftRed = new int[beads.length + 1];
        aftBlue[beads.length]
                = aftRed[beads.length]
                = 0;
        for (int i = beads.length - 1; i >= 0; i--) {
            if (beads[i] == 'b') {
                aftBlue[i] = aftBlue[i + 1] + 1;
                aftRed[i] = 0;
            } else if (beads[i] == 'r') {
                aftBlue[i] = 0;
                aftRed[i] = aftRed[i + 1] + 1;
            } else {
                // beads[i] == 'w'
                aftBlue[i] = aftBlue[i + 1] + 1;
                aftRed[i] = aftRed[i + 1] + 1;
            }
        }

        int sum = 0;
        for (int i = 0; i < beads.length; i++) {
            sum = Math.max(sum,
                    Math.max(befBlue[i] + aftRed[i],
                            befRed[i] + aftBlue[i]));
        }
        out.println(sum > N ? N : sum);

        in.close();
        out.close();
        System.exit(0);
    }