char s[4];i;main(){i=scanf("%d%3s",&i,s)>puts(i<2||i<4&&*s-s[1]&&s[1]-s[2]?"NO":"YES");}