import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  } main {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    } {
      sc.close();
    } sc.close() sc.close sc {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } String s = sc.next(); s sc.next() sc.next sc int n = s.length(); n s.length() s.length s Deque<Integer> st = new ArrayDeque<Integer>(); st new ArrayDeque<Integer>() for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      } {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      } int c = s.charAt(i); c s.charAt(i) s.charAt s i if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        } st.isEmpty() || st.peek() == c st.isEmpty() st.isEmpty st st.peek() == c st.peek() st.peek st c {
          st.push(c);
        } st.push(c) st.push st c {
          st.pop();
        } st.pop() st.pop st System.out.println(n - st.size()) System.out.println System.out System System.out n - st.size() n st.size() st.size st String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  }
} Main
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      String s = sc.next();
      int n = s.length();
      Deque<Integer> st = new ArrayDeque<Integer>();

      for (int i = 0; i < n; i++) {
        int c = s.charAt(i);
        if (st.isEmpty() || st.peek() == c) {
          st.push(c);
        } else {
          st.pop();
        }
      }
      System.out.println(n - st.size());
    } finally {
      sc.close();
    }
  }
}