import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	} main {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc sc = null sc null StringBuilder sb = new StringBuilder(s); sb new StringBuilder(s) StringBuilder pres; pres int l1 = s.length(); l1 s.length() s.length s while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		} true {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		} pres = sb pres sb for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			} int i = sb.length()-2; int i = sb.length()-2; i sb.length()-2 sb.length() sb.length sb 2 i >=0 i 0 i-- i-- i {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			} {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			} if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				} sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0')) sb.length() > i + 1 sb.length() sb.length sb i + 1 i 1 ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0')) (sb.charAt(i) == '0' && sb.charAt(i+1) == '1') sb.charAt(i) == '0' sb.charAt(i) sb.charAt sb i '0' sb.charAt(i+1) == '1' sb.charAt(i+1) sb.charAt sb i+1 i 1 '1' (sb.charAt(i) == '1' && sb.charAt(i+1) == '0') sb.charAt(i) == '1' sb.charAt(i) sb.charAt sb i '1' sb.charAt(i+1) == '0' sb.charAt(i+1) sb.charAt sb i+1 i 1 '0' {
					sb.replace(i, i+2, "");
				} sb.replace(i, i+2, "") sb.replace sb i i+2 i 2 "" if(pres.equals(sb)) break; pres.equals(sb) pres.equals pres sb break; System.out.println(l1 - sb.length()) System.out.println System.out System System.out l1 - sb.length() l1 sb.length() sb.length sb String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc = null;
		StringBuilder sb = new StringBuilder(s);
		StringBuilder pres;
		int l1 = s.length();
		while(true) {
			pres = sb;
			for(int i = sb.length()-2; i >=0; i--) {
				if(sb.length() > i + 1 &&
				   ((sb.charAt(i) == '0' && sb.charAt(i+1) == '1') ||
				   (sb.charAt(i) == '1' && sb.charAt(i+1) == '0'))) {
					sb.replace(i, i+2, "");
				}
			}
			if(pres.equals(sb)) break;
		}
		System.out.println(l1 - sb.length());
	}
}
