'use strict'

const main = input => {
	const n = input.trim()
	if (n[0] === n[1] && n[1] === n[2]) console.log('Yes')
	else if (n[1] === n[2] && n[2] === n[3]) console.log('Yes')
	else console.log('No')
}

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