#if os(Linux)
    import Glibc
#else
    import Darwin
#endif

import Foundation

let N = readLine()!
if N[N.startIndex] == N[N.index(after: N.startIndex)],
    N[N.index(after: N.startIndex)] == N[N.index(N.startIndex, offsetBy: 2)] {
    print("Yes")
} else if N[N.index(after: N.startIndex)] == N[N.index(N.startIndex, offsetBy: 2)],
    N[N.index(N.startIndex, offsetBy: 2)] == N[N.index(N.startIndex, offsetBy: 3)] {
    print("Yes")
} else {
    print("No")
}
