#include <bits/stdc++.h>
using namespace std;
int main()
{
    char s1[10];
    cin>>s1;
    if(s1[0]==s1[1] && s1[1]==s1[2] || s1[1]==s1[2] && s1[2]==s1[3])
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


