Lang:Python2
Edit12345678910111213141516171819202122#!/usr/bin/env python# -*- coding: utf-8 -*-def best(string):# 1 <= S <= 1000min = 1000for i in range(len(string) + 1):m = string[0:i].count('1') + string[i:].count('0')if min >= m:min = mreturn mindef main():N = input()while N > 0:N -= 1M = raw_input()print best(M)if __name__ == "__main__":main()