/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
} Main public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	} main {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s = br.readLine(); s br.readLine() br.readLine br Stack<Integer> st = new Stack<>(); st new Stack<>() int len = s.length(); len s.length() s.length s int remove = 0; remove 0 for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    } int i = len-1; int i = len-1; i len-1 len 1 i >= 0 i 0 i-- i-- i {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    } {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    } if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        } st.empty() st.empty st {
	            st.push(i);
	        } st.push(i) st.push st i if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        } s.charAt(st.peek()) == s.charAt(i) s.charAt(st.peek()) s.charAt s st.peek() st.peek st s.charAt(i) s.charAt s i {
	            st.push(i);
	        } st.push(i) st.push st i {
	            st.pop();
	            remove++;
	        } st.pop() st.pop st remove++ remove System.out.println(((long)remove)*2L) System.out.println System.out System System.out ((long)remove)*2L ((long)remove) 2L String[] args args public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
} public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
} Main
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = br.readLine();
	    Stack<Integer> st = new Stack<>();
	    
	    
	    int len = s.length();
	    int remove = 0;
	    for(int i = len-1; i >= 0; i--) {
	        if(st.empty()) {
	            st.push(i);
	        } else if(s.charAt(st.peek()) == s.charAt(i)) {
	            st.push(i);
	        } else {
	            st.pop();
	            remove++;
	        }
	    }
	    
		System.out.println(((long)remove)*2L);
	}
}
