#include <stdio.h>

struct byte{
	char c[8];
}b;

bool inbyte(){
	for(int i=0; i<8; i++){
		scanf("%c", &(b.c[i]));
		if(feof(stdin) || b.c[i] == '\n'){
			return false;
		}
	}
	return true;
}
int main(){
	b.c[0] = '0';
	int numloc = 0;
	while(inbyte() == true){
		if(b.c[0] == '1'){
			if(numloc != 0){
				printf("NO");
				return 0;
			}
			for(int i=7; i>0; i--){
				if(b.c[i] == '0') numloc++;
				else break;
			}
		}
		else{
			numloc--;
		}
		//	printf("NUMLOC = %i\n", &numloc);
	}
	//printf("NUMLOC = %i\n", &numloc);
	if(numloc != 0){printf("NO");}
	else printf("YES");
	return 0;
}