(define s(read-line))
(define n(string-size s))
(define nn n)
(define p 0)
(define q 0)
(define i 0)
(while(< i 50000)
	(set! p(string-scan s"01"))
	(when p
		(if(< 0 p(- n 2))
			(set! s(string-append(substring s 0 p)(substring s(+ p 2)n)))
			(if(= p 0)
				(set! s(substring s 2 n))
				(set! s(substring s 0 p))
			)
		)
		(dec! n 2)
	)
	(set! q(string-scan s"10"))
	(when q
		(if(< 0 q(- n 2))
			(set! s(string-append(substring s 0 q)(substring s(+ q 2)n)))
			(if(= q 0)
				(set! s(substring s 2 n))
				(set! s(substring s 0 q))
			)
		)
		(dec! n 2)
	)
	(when(and(not p)(not q))(print(- nn n))(exit 0))
	(inc! i)
)
(print(- nn n))