(define(vr v k)(vector-ref v k))
(define(vs v k a)(vector-set! v k a))
(define(mv n a)(make-vector n a))
(define(vvr v y x X)(vector-ref v(+(* y X)x)))
(define(vvs v y x X a)(vector-set! v(+(* y X)x)a))

(define(mktm a b)(make-tree-map a b))
(define(tmpt t k v)(tree-map-put! t k v))
(define(tmgt t k)(tree-map-get t k))
(define(tmex? t k)(tree-map-exists? t k))
(define(tmfl? t)(not(tree-map-empty? t)))
(define(tpmi t)(tree-map-pop-min! t))
(define(tpma t)(tree-map-pop-max! t))

(define(mp a b)(+(*(expt 10 6)a)b))
(define(fi p)(div p(expt 10 6)))
(define(se p)(mod p(expt 10 6)))

(define s(read-line))
(define n(string-size s))
(define nn n)
(define p 0)
(define q 0)
(define i 0)
(while(< i 100000)
	(set! p(string-scan-right 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-right 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))