void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s=readln.chomp.to!(char[]);

  foreach(i; 0..10){
    char[] t;
    foreach(_; 0..3) t~=i+'0';
    if(s[0..($-1)]==t){writeln("Yes"); return;}
    if(s[1..$]==t){writeln("Yes"); return;}
  }

  writeln("No");
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}