#include std::string s; int maxDepth, steps, bestSteps, p; void doit(int curDep) { if (s[p++] == '0') return; ++steps; if (++curDep > maxDepth) maxDepth = curDep, bestSteps = steps; doit(curDep), doit(curDep); } int main() { for (int c = 0; c < 10; ++c) std::cin >> s >> s, maxDepth = -1, steps = 0, bestSteps = -1, p = 0, doit(0), std::cout << bestSteps << std::endl; }