In order to combat potato cruelty in Potatoland, Jiahai is running for election. Jiahai has one competitor, Guan, who is trying to win the election as well. Potatoland consists of a series of N small houses on a straight main road, numbered from 0 to N-1. Before the election, Jiahai has already conducted polls and has found out who each house will vote for.
However, here is the problem. The electorial system is really stupid, and it allows Jiahai to split this road up into segments of at least length L where each segment constitutes an "electorial division". Each electorial division will cast one electorial vote based on its majority. (If Jiahai wins exactly half, Guan has the majority) Jiahai wants to maximise his winning margin, which is defined as (number of electorial votes cast for Jiahai) - (number of electorial votes cast for Guan). Help Jiahai find out what is the maximum possible winning margin. (It can be negative, if Jiahai is sure to lose.)
8 3 JGJGGGGJ
13 3 JJGGJJGGGGJJJ