import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    } main {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc int cnt = 0; cnt 0 int red = 0; red 0 int blue = 0; blue 0 for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        } {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        } if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            } s.charAt(i) == '0' s.charAt(i) s.charAt s i '0' {
                red++;
            } red++ red {
                blue++;
            } blue++ blue if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            } i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1) i != s.length() - 1 i s.length() - 1 s.length() s.length s 1 s.charAt(i) != s.charAt(i + 1) s.charAt(i) s.charAt s i s.charAt(i + 1) s.charAt s i + 1 i 1 {
                cnt++;
            } cnt++ cnt int temp = Math.min(red - cnt, blue - cnt); temp Math.min(red - cnt, blue - cnt) Math.min Math red - cnt red cnt blue - cnt blue cnt System.out.println(cnt * 2 + temp * 2) System.out.println System.out System System.out cnt * 2 + temp * 2 cnt * 2 cnt 2 temp * 2 temp 2 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                red++;
            } else {
                blue++;
            }
            if (i != s.length() - 1 && s.charAt(i) != s.charAt(i + 1)) {
                cnt++;
            }
        }
        int temp = Math.min(red - cnt, blue - cnt);
        System.out.println(cnt * 2 + temp * 2);
    }
}