using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int[] inpt = Reader.ReadLine().Reverse().Select(a=>int.Parse(a.ToString())).ToArray(); string ans = "No"; if(IsValid(inpt)) { ans = "Yes"; } Console.WriteLine(ans); } private bool IsValid(int[] inpt) { for (int i = 0; i < inpt.Length; i++) { int num = inpt[i]; if(i==0) { if(num >=2&&num>=4) { continue; } else { return false; } } else if(i == inpt.Length - 1) { if(num==1) { return true; } else { return false; } } else { if(num >= 3&&num<=5) { continue; } else if(num == 7 || num == 8) { for (int j = i + 1; j < inpt.Length; j++) { if(inpt[j] != 6 && inpt[j] != 7) { return false; } } return true; } } } return true; } public class Reader { static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 705911737388353116828094829003413704629848147168047231489065274555933653942366096911323010774858296427342698920410286577728729557460839940538292739697050439544382252166872338933802404281706677280549061989461946673972768806628894288342003639214736129235569394922691973731136327130284384467284019748893960783101294913838476782983515562520429968832982319478460321360248255802904684923590893984528257497760973143333280874931796396855943260254079589491340130847790154376182849959172915187060421666913788124937616351122761325045424659946555371334347657441496108933159833421760273570798848469191034932947959370908838624829366880235282717924258951684133606033616031903302526852483735538689074308322968417766137054608678256672870631936874436815894900020588414526296716750357655749767859209597429343411364558534553163118938109462998611218261767748601048959463112383674026288927336017647470686849399230609501652661893493545672433267279166614907213719714236160948904457114550678750877008909523331916526198537851144882033586720224382826099769795898848521481583657620701705315711367058907749958010699260726184485822266594574856625623964800530850144165231145219223468405841812121941710768268269959255693592068214682173866308365847426201639016902822540005789439965216167372723357482654653404900483553773746461841144784076324376929920671480553248806502579268969021623414358456842118923923520596593091529736467672035320680864797401794372279887791220741099685283783893152695869343789376743682123695658509612216521802377054409868389336850391270100655769535597600661533274416837273895246505094878507522359697161017963141235485780055120516357809643799196957806045171657239336871895733042416759817889592360225648728619917280443664930727412293880313704635308162773893149866456817473213025837352214114648034166388052223676003114566227186760002981091101109416235088575878116345218590381999803527056119548542250936888251809076308255108628316175106419937671712632251327536957108233094270493070817165367072054957755574423650576924235668958813369568425316353682032108850119886564706307823637654113335827396989669318253325404996311503811424014470793272414268025892256107469501921888137110582141788760829632773564409799959590710896158277615173835280325135088365230971103189921652873288396869641474030460687091983183930885339660856954828075304668336759343317102234196046695938963331657274193359001833838755259877240405153522458748421577781879886446854514254616949413226084634966172798323086859286017482488449606278066052815431713827792048085791000589841203648465917037684019840418485519806743295842902384890544149817210131730942901137230384207979019310130524201714786114516711954772739317086886919646605953911821158517701891974821525347061911545444677868675259463583667338316548724165780770839689580528642103930810915266766580527270851359721378373495083202485366195099509160037363072349797206805295021615434808345299736019278324552454647287068424802058520256990154735312414806336920891745690260534260467844 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }