
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	}

} 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.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.next(); input sc.next() sc.next sc sc.close() sc.close sc int ans = 0; ans 0 StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = input.length(); n input.length() input.length input int i = 0; i 0 while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		} i < n i n {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		} char x = 'x'; x 'x' if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1); sb.length() != 0 sb.length() sb.length sb 0 x = sb.charAt(sb.length() - 1) x sb.charAt(sb.length() - 1) sb.charAt sb sb.length() - 1 sb.length() sb.length sb 1 char y = input.charAt(i); y input.charAt(i) input.charAt input i if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			} sb.length() != 0 sb.length() sb.length sb 0 {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y); x != y x y {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} ans += 2 ans 2 sb.deleteCharAt(sb.length() - 1) sb.deleteCharAt sb sb.length() - 1 sb.length() sb.length sb 1 sb.append(y) sb.append sb y {
				sb.append(y);
			} sb.append(y) sb.append sb y i++ i 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);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		int ans = 0;
		StringBuilder sb = new StringBuilder();
		int n = input.length();
		int i = 0;
		while (i < n) {
			char x = 'x';
			if (sb.length() != 0)
				x = sb.charAt(sb.length() - 1);
			char y = input.charAt(i);
			if (sb.length() != 0) {
				if (x != y) {
					ans += 2;
					sb.deleteCharAt(sb.length() - 1);
				} else
					sb.append(y);
			} else {
				sb.append(y);
			}
			// if (sb.length() != 0)
			// x = 'x';
			i++;
		}
		System.out.println(ans);
	}

}
