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

public class Main {

    public static String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    }
} 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 String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    }
} Main public static String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    } process {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    } final String S = testCase.S; S testCase.S testCase testCase.S final char[] chars = S.toCharArray(); chars S.toCharArray() S.toCharArray S int count = 0; count 0 Deque<Character> stack = new ArrayDeque<>(); stack new ArrayDeque<>() for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        } char c chars {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        } {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        } if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            } stack.isEmpty() stack.isEmpty stack {
                stack.push(c);
            } stack.push(c) stack.push stack c {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            } if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                } stack.peek().equals(c) stack.peek().equals stack.peek() stack.peek stack c {
                    stack.push(c);
                } stack.push(c) stack.push stack c {
                    stack.pop();
                    count += 2;
                } stack.pop() stack.pop stack count += 2 count 2 return String.valueOf(count); String.valueOf(count) String.valueOf String count TestCase testCase testCase public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    } main {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    } TestCase testCase = readFromInput(); testCase readFromInput() readFromInput final String result = process(testCase); result process(testCase) process testCase output(result) output result String[] args args private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    } readFromInput {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String S = sc.next(); S sc.next() sc.next sc return new TestCase(S); new TestCase(S) private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    } unknownN {
        return new IllegalArgumentException("Unknown N: " + N);
    } return new IllegalArgumentException("Unknown N: " + N); new IllegalArgumentException("Unknown N: " + N) int N N private static void output(String result) {
        System.out.println(result);
    } output {
        System.out.println(result);
    } System.out.println(result) System.out.println System.out System System.out result String result result public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    } TestCase final String S; S public TestCase(String S) {
            this.S = S;
        } TestCase {
            this.S = S;
        } this.S = S this.S this this.S S String S S public class Main {

    public static String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    }
} public class Main {

    public static String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    }
} Main
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static String process(TestCase testCase) {
        final String S = testCase.S;

        final char[] chars = S.toCharArray();

        int count = 0;
        Deque<Character> stack = new ArrayDeque<>();
        for (char c : chars) {
            if (stack.isEmpty()) {
                stack.push(c);
            } else {
                if (stack.peek().equals(c)) {
                    stack.push(c);
                } else {
                    stack.pop();
                    count += 2;
                }
            }
        }

        return String.valueOf(count);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        return new TestCase(S);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String S;

        public TestCase(String S) {
            this.S = S;
        }
    }
}
