import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc int count = 0; count 0 String inputStr[] = new String[input.length()]; inputStr new String[input.length()] input.length() input.length input int currentIndex = 0; currentIndex 0 for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		} int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		} {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		} inputStr[currentIndex]= input.substring(i,i+1) inputStr[currentIndex] inputStr currentIndex input.substring(i,i+1) input.substring input i i+1 i 1 if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			} currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1]) currentIndex!=0 currentIndex 0 !inputStr[currentIndex].equals(inputStr[currentIndex-1]) inputStr[currentIndex].equals(inputStr[currentIndex-1]) inputStr[currentIndex].equals inputStr[currentIndex] inputStr currentIndex inputStr[currentIndex-1] inputStr currentIndex-1 currentIndex 1 {
				currentIndex--;
				count+=2;
			} currentIndex-- currentIndex count+=2 count 2 {
				currentIndex++;
			} currentIndex++ currentIndex System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();

		int count = 0;
		String inputStr[] = new String[input.length()];
		int currentIndex = 0;
		for(int i = 0; i < input.length(); i++) {
			inputStr[currentIndex]= input.substring(i,i+1);
			if(currentIndex!=0 && !inputStr[currentIndex].equals(inputStr[currentIndex-1])) {
				currentIndex--;
				count+=2;
			}else {
				currentIndex++;
			}
		}
		System.out.println(count);
		sc.close();
	}
}
