import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    }
} import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    } main {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    } try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        } {
            new Main().solve(sc);
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) new Main().solve(sc) new Main().solve new Main() sc String[] args args void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    } solve {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    } char[] s = sc.next().toCharArray(); s sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc Queue<Character> stack = new LinkedList<>(); stack new LinkedList<>() int ans = 0; ans 0 for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        } char c s {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        } {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        } if (stack.isEmpty()) {
                stack.add(c);
                continue;
            } stack.isEmpty() stack.isEmpty stack {
                stack.add(c);
                continue;
            } stack.add(c) stack.add stack c continue; if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            } stack.peek() != c stack.peek() stack.peek stack c {
                ans += 2;
                stack.poll();
            } ans += 2 ans 2 stack.poll() stack.poll stack {
                stack.add(c);
            } stack.add(c) stack.add stack c System.out.println(ans) System.out.println System.out System System.out ans Scanner sc sc public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        Queue<Character> stack = new LinkedList<>();
        int ans = 0;
        for (char c : s) {
            if (stack.isEmpty()) {
                stack.add(c);
                continue;
            }

            if (stack.peek() != c) {
                ans += 2;
                stack.poll();
            } else {
                stack.add(c);
            }
        }
        System.out.println(ans);
    }
}