function main(int) {
	const chars = int.toString().split('');
	const head = chars[0];
	const tail = chars[3];
	const isGood =
		(chars[1] == head && chars[2] == head) ||
		(chars[1] == tail && chars[2] == tail);
	console.log(isGood ? 'Yes' : 'No');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
