import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  } Scanner sc =  new Scanner(System.in); sc new Scanner(System.in) String S = sc.nextLine(); S sc.nextLine() sc.nextLine sc char c = S.charAt(0); c S.charAt(0) S.charAt S 0 int count = 1; count 1 int ans = 0; ans 0 for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    } int i = 1; int i = 1; i 1 i < S.length() i S.length() S.length S i++ i++ i {
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    } {
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    } if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      } count == 0 count 0 {
        c = S.charAt(i);
        count++;
      } c = S.charAt(i) c S.charAt(i) S.charAt S i count++ count if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      } c == S.charAt(i) c S.charAt(i) S.charAt S i {
        count++;
      } count++ count {
        count--;
        ans += 2;
      } count-- count ans += 2 ans 2 System.out.println(ans) System.out.println System.out System System.out ans String[]args args public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    char c = S.charAt(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < S.length(); i++){
      if(count == 0){
        c = S.charAt(i);
        count++;
      }else if(c == S.charAt(i)){
        count++;
      }else{
        count--;
        ans += 2;
      }
    }
    System.out.println(ans);
  }
}