import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  }
} import java.util.*; util.* java public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

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

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  } main {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  } String S = sc.next(); S sc.next() sc.next sc char[] ch = S.toCharArray(); ch S.toCharArray() S.toCharArray S ArrayList list = new ArrayList(); list new ArrayList() for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    } int i=0; int i=0; i 0 i<ch.length i ch.length ch ch.length i++ i++ i {
      list.add(ch[i]);
    } {
      list.add(ch[i]);
    } list.add(ch[i]) list.add list ch[i] ch i for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    } int i=0; int i=0; i 0 i<=list.size()-2 i list.size()-2 list.size() list.size list 2 i++ i++ i {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    } {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    } if (i<0) i = 0; i<0 i 0 i = 0 i 0 if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      } list.get(i) != list.get(i+1) list.get(i) list.get list i list.get(i+1) list.get list i+1 i 1 {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      } list.remove(i+1) list.remove list i+1 i 1 list.remove(i) list.remove list i i -= 2 i 2 System.out.println(ch.length - list.size()) System.out.println System.out System System.out ch.length - list.size() ch.length ch ch.length list.size() list.size list String[] args args public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  }
} public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  }
} Main
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    String S = sc.next();

    char[] ch = S.toCharArray();

    ArrayList list = new ArrayList();
    for (int i=0; i<ch.length; i++) {
      list.add(ch[i]);
    }

    for (int i=0; i<=list.size()-2; i++) {
      if (i<0) i = 0;
      if (list.get(i) != list.get(i+1)) {
        list.remove(i+1);
        list.remove(i);
        i -= 2;
      }
    }

    System.out.println(ch.length - list.size());

  }
}