A parity bit, or check bit, is a bit added to the end of a string of bits for error detection. In telecommunications and computing, all data is transformed into a sequence of zeros and ones. For this problem, assume that all information is coded using 8 bits, where the first 7 bits hold the data and the last bit is the parity bit. The parity bit is set to one if the number of ones among the preceding 7 bits is odd, and set to zero if that number is even.
| 7 data bits (count of 1 bits) | 8 bits including the parity bit |
|---|---|
| 0000000 (0) | 00000000 |
| 0101001 (3) | 01010011 |
| 0111001 (4) | 01110010 |
| 0110111 (5) | 01101111 |
| 1001100 (3) | 10011001 |
The parity bit lets you decide whether the data was transmitted incorrectly. If the parity bit is wrong (it does not match the parity of the preceding 7 bits), a parity error has occurred. Read each line of data and determine the number of parity errors on that line.
The first line contains a positive integer: the number of transmitted data lines. Each following line is a sequence of zeros and ones whose length is a multiple of 8 and at most 64.
For each data transmission line, print the number of parity errors found in that line.