#import <Foundation/Foundation.h>
BOOL addition = NO;
int f(int n){
	int result;
	if(n%3==0){
		result = n/3*2;
		addition = NO;
	}else if(n%3==1){
		result = (n-1)/3*2+1;
		addition = NO;
	}else{
		result = (n-2)/3*2+1;
		if(addition){
			result++;
			addition = NO;
		}else{
			addition = YES;
		}
	}
	return result;
}
int main() {
	char prev='\0', c;
	int ans = 0, current = 0;
	while((c=getchar())!='\n'){
		if(c==prev){
			current++;
		}else{
			if(current>0) ans += f(current);
			current = 1;
		}
		prev = c;
	}
	ans += f(current);
	printf("%d\n",ans);
}