class Solution { public: int maxN(string &s) { int res = 0; stack<int> stk; stk.push(0); for (int i = 1; i < s.length(); ++i) { if (s[stk.top()] == '1&(30767)#39; && s[i] == '0') stk.pop(); else stk.push(i); } stk.push(s.length()); int pre = stk.top(); stk.pop(); while (!stk.empty()) { res = max(res, pre - stk.top() - 1); stk.pop(); } return res; } };