import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	} main {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String S = in.next(); S in.next() in.next in StringBuilder sb = new StringBuilder(S); sb new StringBuilder(S) int ans = 0; ans 0 for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		} int i = sb.length() - 2; int i = sb.length() - 2; i sb.length() - 2 sb.length() sb.length sb 2 i >= 0 i 0 i-- i-- i {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		} {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		} if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			} i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1) i + 1 < sb.length() i + 1 i 1 sb.length() sb.length sb sb.charAt(i) != sb.charAt(i + 1) sb.charAt(i) sb.charAt sb i sb.charAt(i + 1) sb.charAt sb i + 1 i 1 {
				sb.delete(i, i + 2);
				ans += 2;
			} sb.delete(i, i + 2) sb.delete sb i i + 2 i 2 ans += 2 ans 2 System.out.println(ans) System.out.println System.out System System.out ans in.close() in.close in String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		StringBuilder sb = new StringBuilder(S);
		int ans = 0;
		for (int i = sb.length() - 2; i >= 0; i--) {
			if (i + 1 < sb.length() && sb.charAt(i) != sb.charAt(i + 1)) {
				sb.delete(i, i + 2);
				ans += 2;
			}
		}
		System.out.println(ans);
		in.close();
	}
}