import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        }

        int cnt = N;
        while (!stack.empty()) {
            stack.pop();
            cnt--;
        }

        System.out.println(cnt);

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        }

        int cnt = N;
        while (!stack.empty()) {
            stack.pop();
            cnt--;
        }

        System.out.println(cnt);

        return;
    }

} Solver public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        }

        int cnt = N;
        while (!stack.empty()) {
            stack.pop();
            cnt--;
        }

        System.out.println(cnt);

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        }

        int cnt = N;
        while (!stack.empty()) {
            stack.pop();
            cnt--;
        }

        System.out.println(cnt);

        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] S = sc.next().toCharArray(); S sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc int N = S.length; N S.length S S.length Stack<Character> stack = new Stack<>(); stack new Stack<>() for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        } int i = 0; int i = 0; i 0 i < S.length i S.length S S.length i++ i++ i {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        } {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        } char ch = S[i]; ch S[i] S i if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            } stack.empty() stack.empty stack {
                stack.push(ch);
            } stack.push(ch) stack.push stack ch {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            } if (ch == stack.peek()) stack.push(ch);
                else stack.pop(); ch == stack.peek() ch stack.peek() stack.peek stack stack.push(ch) stack.push stack ch stack.pop() stack.pop stack int cnt = N; cnt N while (!stack.empty()) {
            stack.pop();
            cnt--;
        } !stack.empty() stack.empty() stack.empty stack {
            stack.pop();
            cnt--;
        } stack.pop() stack.pop stack cnt-- cnt System.out.println(cnt) System.out.println System.out System System.out cnt return;
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;

        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < S.length; i++) {
            char ch = S[i];
            if (stack.empty()) {
                stack.push(ch);
            } else {
                if (ch == stack.peek()) stack.push(ch);
                else stack.pop();
            }
        }

        int cnt = N;
        while (!stack.empty()) {
            stack.pop();
            cnt--;
        }

        System.out.println(cnt);

        return;
    }

}
