import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    }

} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc sc.close() sc.close sc Stack<Integer> stack = new Stack<>(); stack new Stack<>() int ans = 0; ans 0 int leftIndex = 0; leftIndex 0 int rightIndex = 1; rightIndex 1 while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        } rightIndex < s.length() rightIndex s.length() s.length s {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        } if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            } s.charAt(leftIndex) != s.charAt(rightIndex) s.charAt(leftIndex) s.charAt s leftIndex s.charAt(rightIndex) s.charAt s rightIndex {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } ans += 2 ans 2 if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                } stack.empty() stack.empty stack {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } leftIndex = rightIndex + 1 leftIndex rightIndex + 1 rightIndex 1 rightIndex = rightIndex + 2 rightIndex rightIndex + 2 rightIndex 2 {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                } leftIndex = stack.pop() leftIndex stack.pop() stack.pop stack rightIndex = rightIndex + 1 rightIndex rightIndex + 1 rightIndex 1 {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            } stack.push(leftIndex) stack.push stack leftIndex leftIndex = rightIndex leftIndex rightIndex rightIndex = rightIndex + 1 rightIndex rightIndex + 1 rightIndex 1 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 s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    }

} Main
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        int leftIndex = 0;
        int rightIndex = 1;
        while (rightIndex < s.length()) {
            if (s.charAt(leftIndex) != s.charAt(rightIndex)) {
                ans += 2;
                if (stack.empty()) {
                    leftIndex = rightIndex + 1;
                    rightIndex = rightIndex + 2;
                } else {
                    leftIndex = stack.pop();
                    rightIndex = rightIndex + 1;
                }
            } else {
                stack.push(leftIndex);
                leftIndex = rightIndex;
                rightIndex = rightIndex + 1;
            }
        }
        System.out.println(ans);
    }

}
