#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
bool valid(int i) {
    if(i >= 0 && i <= 255) return true;
    return false;
}

int main() {
    int i1,i2,i3,i4;
    char ip[20];
    while (fgets(ip, sizeof(ip), stdin) != NULL) {
        int count = 0;
        int otherchar = 0;
        int startnum = 0;
        int isstart = 1;
        int startwithzero = 0;
        for(int i = 0; ip[i] != '\n' && ip[i] != '\0'; i++) {
            if(ip[i] == '.') {
                count++;
                isstart = 1;
            }
            else if(!isdigit(ip[i])) {
                otherchar = 1;
            } else {
                if(isstart && (i + 1 != '\n') && (i + 1 != '\0')) {
                    if(ip[i] == '0' && isdigit(ip[i + 1])) {
                        startwithzero = 1;
                    }
                }
                isstart = 0;
            }
        }
        if(count != 3 || otherchar == 1 || startwithzero == 1) {
            printf("NO\n");
            continue;
        }
        sscanf(ip,"%d.%d.%d.%d", &i1, &i2, &i3, &i4);
        if(valid(i1) && valid(i2) && valid(i3) && valid(i4)) {
            printf("YES\n");
        } else{
            printf("NO\n");
        }
    }
    return 0;
}