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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.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 scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) StringBuilder s = new StringBuilder(scanner.next()); s new StringBuilder(scanner.next()) Deque<String> stack = new ArrayDeque<>(); stack new ArrayDeque<>() for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		} {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		} if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			} stack.size()==0 stack.size() stack.size stack 0 {
				stack.push(s.substring(i, i+1));
			} stack.push(s.substring(i, i+1)) stack.push stack s.substring(i, i+1) s.substring s i i+1 i 1 {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			} if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				} !stack.peek().equals(s.substring(i, i+1)) stack.peek().equals(s.substring(i, i+1)) stack.peek().equals stack.peek() stack.peek stack s.substring(i, i+1) s.substring s i i+1 i 1 {
					stack.pop();
				} stack.pop() stack.pop stack {
					stack.push(s.substring(i, i+1));
				} stack.push(s.substring(i, i+1)) stack.push stack s.substring(i, i+1) s.substring s i i+1 i 1 System.out.println(s.length()-stack.size()) System.out.println System.out System System.out s.length()-stack.size() s.length() s.length s stack.size() stack.size stack scanner.close() scanner.close scanner String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	}
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder s = new StringBuilder(scanner.next());
		Deque<String> stack = new ArrayDeque<>();
		for(int i=0; i<s.length(); i++) {
			if(stack.size()==0) {
				stack.push(s.substring(i, i+1));
			}
			else {
				if(!stack.peek().equals(s.substring(i, i+1))) {
					stack.pop();
				}
				else {
					stack.push(s.substring(i, i+1));
				}
			}
		}

		System.out.println(s.length()-stack.size());
		scanner.close();
	}
}