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

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

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  }
} import java.util.Scanner; Scanner java.util import java.util.Stack; Stack java.util public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  } main {
    Scanner scanner = new Scanner(System.in);

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) Stack<Character> stack = new Stack<>(); stack new Stack<>() char[] s = scanner.next().toCharArray(); s scanner.next().toCharArray() scanner.next().toCharArray scanner.next() scanner.next scanner int N = s.length; N s.length s s.length for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    } char c s {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    } {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    } if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c); !stack.isEmpty() && stack.peek() != c !stack.isEmpty() stack.isEmpty() stack.isEmpty stack stack.peek() != c stack.peek() stack.peek stack c stack.pop() stack.pop stack stack.add(c) stack.add stack c System.out.println(N - stack.size()) System.out.println System.out System System.out N - stack.size() N stack.size() stack.size stack String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  }
} Main
import java.util.Scanner;
import java.util.Stack;

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

    Stack<Character> stack = new Stack<>();
    char[] s = scanner.next().toCharArray();
    int N = s.length;
    for (char c : s) {
      if (!stack.isEmpty() && stack.peek() != c) stack.pop();
      else stack.add(c);
    }
    System.out.println(N - stack.size());
  }
}
