import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Deque; Deque java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Deque<Integer> deq = new ArrayDeque<Integer>(); deq new ArrayDeque<Integer>() int count = 1; count 1 for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		} int i = 1; int i = 1; i 1 i < s.length i s.length s s.length i++ i++ i {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		} {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		} if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			} s[i]==s[i-1] s[i] s i s[i-1] s i-1 i 1 {
				count++;
			} count++ count {
				deq.addLast(count);
				count = 1;
			} deq.addLast(count) deq.addLast deq count count = 1 count 1 deq.addLast(count) deq.addLast deq count int ans = deq.pollFirst(); ans deq.pollFirst() deq.pollFirst deq while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		} !deq.isEmpty() deq.isEmpty() deq.isEmpty deq {
			ans = deq.pollFirst()-ans;
		} ans = deq.pollFirst()-ans ans deq.pollFirst()-ans deq.pollFirst() deq.pollFirst deq ans System.out.println(s.length-Math.abs(ans)) System.out.println System.out System System.out s.length-Math.abs(ans) s.length s s.length Math.abs(ans) Math.abs Math ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		Deque<Integer> deq = new ArrayDeque<Integer>();

		int count = 1;
		for (int i = 1; i < s.length; i++) {
			if(s[i]==s[i-1]) {
				count++;
			}else {
				deq.addLast(count);
				count = 1;
			}
		}
		deq.addLast(count);

		int ans = deq.pollFirst();
		while(!deq.isEmpty()) {
			ans = deq.pollFirst()-ans;
		}
		System.out.println(s.length-Math.abs(ans));
		sc.close();
	}
}