import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	} 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 Stack<Character> stack = new Stack<>(); stack new Stack<>() int ans = 0; ans 0 for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		} char s S {
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		} {
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		} if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			} stack.size() <= 0 stack.size() stack.size stack 0 {
				stack.add(s);
			} stack.add(s) stack.add stack s if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			} stack.get(stack.size()-1) != s stack.get(stack.size()-1) stack.get stack stack.size()-1 stack.size() stack.size stack 1 s {
				stack.pop();
				ans += 2;
			} stack.pop() stack.pop stack ans += 2 ans 2 {
				stack.add(s);
			} stack.add(s) stack.add stack s System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();

		Stack<Character> stack = new Stack<>();

		int ans = 0;
		for (char s : S){
			if (stack.size() <= 0){
				stack.add(s);
			}else if (stack.get(stack.size()-1) != s){
				stack.pop();
				ans += 2;
			}else {
				stack.add(s);
			}
		}
		System.out.println(ans);
	}
}