import java.util.Scanner object Main { def max(a: Int, b: Int): Int = { if (a < b) b else a } def min(a: Int, b: Int): Int = { if (a < b) a else b } def solve(sc: => Scanner): Unit = { val s = sc.next val (_, _, _, mn, _) = (s + ' ').foldLeft((0, 0, 0, 0, ' '))((acc, c) => (acc, c) match { case ((cn, pn, p2n, mn, pc), c) if pc != c => (1, cn, pn, max(mn, min(cn+p2n, pn)), c) case ((cn, pn, p2n, mn, pc), c) => (cn + 1, pn, p2n, mn, c) }) println(mn*2) } def main(args: Array[String]): Unit = { val sc: Scanner = new Scanner(System.in) solve(sc) } }