#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
string ip;
cin >> ip;
if (count(ip.begin(), ip.end(), '.') < 3 || count(ip.begin(), ip.end(), '.') > 3) {
cout << "NO" << endl;
return 0;
}
string temp;
vector<int> IP;
for (char ch : ip) {
if (ch >= '0' && ch <= '9') {
temp.push_back(ch);
}
else if (ch == '.') {
if (!temp.empty() && !(temp.length() > 1 && temp[0] == '0')) {
IP.push_back(stoi(temp));
temp.clear();
}
}
else {
cout << "NO" << endl;
return 0;
}
}
if (!temp.empty() && !(temp.length() > 1 && temp[0] == '0')) IP.push_back(stoi(temp));
if (IP.size() < 4 || IP.size() > 4) {
cout << "NO" << endl;
return 0;
}
for (int i = 0; i < IP.size(); i++) {
if (IP[i] < 0 || IP[i] > 255) {
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
}