You are a binary string A consisting of 0s and 1s only. You are allowed to do exactly one move that is you have to choose two indices i and j (1 ≤ i ≤ j ≤ |A| where |A| is string length) and toggle all the characters at position k where i ≤ k ≤ j. Toggling means changing 0 to 1 and 1 to 0.
The task is that after exactly one move you have to obtain the maximum possible number of 1's.
The first line contains the number of test cases T. Each test case contains a string S consisting of 0s and 1s only.
Corresponding to each test case, in a new line, print the maximal number of 1's that can be obtained after exactly one move.
1 ≤ T ≤ 200
1 ≤ Length of string≤ 1005
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.