#include <iostream>
#include <stack>
#include <map>
#include <queue>
#include <string>
#include <sstream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;
bool f1(string s)
{
    if(s[0]==s[1]&&s[1]==s[2]) return 1;
    else if(s[1]==s[2]&&s[2]==s[3]) return 1;
    else return 0;
}

int main()
{
    string s;
    cin>>s;
    if(f1(s)) cout<<"Yes";
    else cout<<"No";
    return 0;
}
