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

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	}

} import java.util.ArrayDeque; ArrayDeque java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	}

} Main public static void main(String[] args) {
		Main main = new Main();
		main.run();
	} main {
		Main main = new Main();
		main.run();
	} Main main = new Main(); main new Main() main.run() main.run main String[] args args public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	} run {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		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 int ans = 0; ans 0 ArrayDeque<Character> st = new ArrayDeque<Character>(); st new ArrayDeque<Character>() st.push(s[0]) st.push st s[0] s 0 for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		} int i=1; int i=1; i 1 i<s.length i s.length s s.length i++ i++ i {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		} {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		} if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			} st.isEmpty() || s[i] == st.getFirst() st.isEmpty() st.isEmpty st s[i] == st.getFirst() s[i] s i st.getFirst() st.getFirst st {
				st.push(s[i]);
			} st.push(s[i]) st.push st s[i] s i {
				st.pop();
				ans++;
			} st.pop() st.pop st ans++ ans System.out.println(ans*2) System.out.println System.out System System.out ans*2 ans 2 sc.close() sc.close sc public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	}

} public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	}

} Main
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		char s[] = sc.next().toCharArray();
		int ans = 0;
		ArrayDeque<Character> st = new ArrayDeque<Character>();
		st.push(s[0]);
		for(int i=1; i<s.length; i++) {
			if(st.isEmpty() || s[i] == st.getFirst()) {
				st.push(s[i]);
			}else {
				st.pop();
				ans++;
			}
		}
		System.out.println(ans*2);
		sc.close();
	}

}
