import java.util.*;

public class Main {
    //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    }

    public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    }
} import java.util.*; util.* java public class Main {
    //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    }

    public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    }
} Main //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) char[] A = sc.next().toCharArray(); A sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc System.out.println(helper(A)) System.out.println System.out System System.out helper(A) helper A sc.close() sc.close sc String[] args args public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    } helper {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    } Stack<Character> stack = new Stack<>(); stack new Stack<>() int res = 0; res 0 for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        } char a A {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        } {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        } if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            } stack.isEmpty() stack.isEmpty stack stack.push(a) stack.push stack a {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            } if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a); stack.peek() != a stack.peek() stack.peek stack a {
                    stack.pop();
                    res += 2;
                } stack.pop() stack.pop stack res += 2 res 2 stack.push(a) stack.push stack a return res; res char[] A A public class Main {
    //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    }

    public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    }
} public class Main {
    //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    }

    public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    }
} Main
import java.util.*;

public class Main {
    //Unification
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] A = sc.next().toCharArray();
        System.out.println(helper(A));
        sc.close();
    }

    public static int helper(char[] A) {
        Stack<Character> stack = new Stack<>();
        int res = 0;
        for (char a : A) {
            if (stack.isEmpty()) stack.push(a);
            else {
                if (stack.peek() != a) {
                    stack.pop();
                    res += 2;
                } else stack.push(a);
            }
        }
        return res;
    }
}
