
import java.util.Scanner;

public class Main {

	static class node{
		int val=-1;
		node prev;
		node next;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	}

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

	static class node{
		int val=-1;
		node prev;
		node next;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	} main {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	} Scanner scn=new Scanner(System.in); scn new Scanner(System.in) String str=scn.next(); str scn.next() scn.next scn int []arr=new int[str.length()]; arr new int[str.length()] str.length() str.length str for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
			arr[i]=str.charAt(i)-'0';
		} {
			arr[i]=str.charAt(i)-'0';
		} arr[i]=str.charAt(i)-'0' arr[i] arr i str.charAt(i)-'0' str.charAt(i) str.charAt str i '0' node start=new node(); start new node() node ptr=new node(); ptr new node() ptr=start ptr start for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		} int i=str.length()-1; int i=str.length()-1; i str.length()-1 str.length() str.length str 1 i>=0 i 0 i-- i-- i {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		} {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		} if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			} start.val==-1 start.val start start.val -1 1 {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			} node n1=new node(); n1 new node() n1.val=arr[i] n1.val n1 n1.val arr[i] arr i n1.prev=null n1.prev n1 n1.prev null n1.next=null n1.next n1 n1.next null start=n1 start n1 ptr=start ptr start if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			} arr[i]==1 arr[i] arr i 1 {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			} if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				} ptr.val==1 ptr.val ptr ptr.val 1 {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				} node n1=new node(); n1 new node() n1.val=arr[i] n1.val n1 n1.val arr[i] arr i n1.prev=ptr n1.prev n1 n1.prev ptr n1.next=null n1.next n1 n1.next null ptr.next=n1 ptr.next ptr ptr.next n1 ptr=n1 ptr n1 {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				} if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					} start!=null&&ptr!=start start!=null start null ptr!=start ptr start {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					} ptr=ptr.prev ptr ptr.prev ptr ptr.prev ptr.next=null ptr.next ptr ptr.next null if(ptr==start) {
						start=new node();
						ptr=start;
					} ptr==start ptr start {
						start=new node();
						ptr=start;
					} start=new node() start new node() ptr=start ptr start {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			} if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				} ptr.val==0 ptr.val ptr ptr.val 0 {
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				} node n1=new node(); n1 new node() n1.val=arr[i] n1.val n1 n1.val arr[i] arr i n1.prev=ptr n1.prev n1 n1.prev ptr n1.next=null n1.next n1 n1.next null ptr.next=n1 ptr.next ptr ptr.next n1 ptr=n1 ptr n1 {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				} if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					} start!=null&&ptr!=start start!=null start null ptr!=start ptr start {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					} ptr=ptr.prev ptr ptr.prev ptr ptr.prev ptr.next=null ptr.next ptr ptr.next null if(ptr==start) {
						start=new node();
						ptr=start;
					} ptr==start ptr start {
						start=new node();
						ptr=start;
					} start=new node() start new node() ptr=start ptr start int cnt=0; cnt 0 while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		} start!=null start null {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		} if(start.val!=-1)
				cnt++; start.val!=-1 start.val start start.val -1 1 cnt++ cnt start=start.next start start.next start start.next System.out.println(str.length()-cnt) System.out.println System.out System System.out str.length()-cnt str.length() str.length str cnt String[] args args static class node{
		int val=-1;
		node prev;
		node next;
	} node int val=-1; val -1 1 node prev; prev node next; next public class Main {

	static class node{
		int val=-1;
		node prev;
		node next;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	}

} public class Main {

	static class node{
		int val=-1;
		node prev;
		node next;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	}

} Main

import java.util.Scanner;

public class Main {

	static class node{
		int val=-1;
		node prev;
		node next;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int []arr=new int[str.length()];
		for(int i=0;i<str.length();i++) {
			arr[i]=str.charAt(i)-'0';
		}
		node start=new node();
		node ptr=new node();
		ptr=start;
		for(int i=str.length()-1;i>=0;i--) {
			if(start.val==-1) {
				node n1=new node();
				n1.val=arr[i];
				n1.prev=null;
				n1.next=null;
				start=n1;
				ptr=start;
			}else if(arr[i]==1) {
				//System.out.println(i);
				if(ptr.val==1) {
					//System.out.println("jj");
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
					
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
			}else {
				
				if(ptr.val==0){
					node n1=new node();
					n1.val=arr[i];
					n1.prev=ptr;
					n1.next=null;
					ptr.next=n1;
					ptr=n1;
				}else {
					if(start!=null&&ptr!=start) {
						//System.out.println("mmmm");
						ptr=ptr.prev;
						ptr.next=null;
					}else if(ptr==start) {
						start=new node();
						ptr=start;
					}
				}
					
				
			}
//			node n=start;
//			while(n!=null) {
//				System.out.print(n.val+" ");
//				n=n.next;
//			}
//			System.out.println("klklklklll"+i);
		}
		int cnt=0;
		while(start!=null) {
			if(start.val!=-1)
				cnt++;
			start=start.next;
			
		}
		System.out.println(str.length()-cnt);
	}

}
