import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;


/**
 * 
 * You must write a method in such a way that it can be used to validate an IP address.
 * Use the following definition of an IP address:

IP address is a string in the form "A.B.C.D", where the value of A, B, C, and D may range
from 0 to 255. Leading zeros are allowed.

Some valid IP address:
000.12.12.034
121.234.12.12
23.45.12.56

Some invalid IP address:
000.12.234.23.23
666.666.23.23
.213.123.23.32
23.45.22.32.
I.Am.not.an.ip
Sample Input
000.12.12.034
121.234.12.12
23.45.12.56
00.12.123.123123.123
122.23
Hello.IP

Sample Output
true
true
true
false
false
false
 * 
 * 
 * 
 * */
class Solution{
	
	public static boolean isValidIP(String ip) {
		if (ip == null || ip.isEmpty()) {
			return false;
		}
		
		String[] parts = ip.split("\\.");
		if (parts.length != 4) {
			return false;
		}
		
		for (String part: parts) {
			if (!isValidSegment(part)) {
				return false;
			}
		}
		return true;
	}
	
	private static boolean isValidSegment(String segment) {
		try {
			int num = Integer.parseInt(segment);
			if (num < 0 || num >  255) {
				return false;
			}
			if (segment.length() > 1 && segment.charAt(0) == '0') {
				return true;
			}
			return true;
		} catch(NumberFormatException e) {
			return false;
		}
	
	}
	
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			String IP = in.next();
			System.out.println(isValidIP(IP));
			System.out.println("IP->"+IP);
		}
	}
	
}