import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class N436 { static int ans=0; static int cnt=0; public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String str=br.readLine(); int c=0,w=0; int[] h=new int[str.length()]; for(int i=0;i=2) { h[i-2]++;h[i-1]++;h[i]++; c=0; cnt++; } else { c=0; } } search(h,0,str.length()-1); System.out.println(ans); } static void search(int[] h,int st,int las) { int sbuf=0; int lbuf=0; if(cnt>0) { while(h[st]!=1) { st++; sbuf++; }sbuf++;//このbufが初めの1を消すまでの工程数 while(h[las]!=1) { las--; lbuf++; }lbuf++; cnt--; if(sbuf<=lbuf) { h[st]=0;h[st+1]=0;h[st+2]=0; ans+=sbuf; search(h,st+1,las); } else { h[las]=0;h[las-1]=0;h[las-2]=0; ans+=lbuf; search(h,st,las-1); } } else { return; } } }