#include<bits/stdc++.h>
using namespace std;
int ud(int a,int b){
return a/b+bool(a%b);
}
int main(){
int m,s,t;
cin>>m>>s>>t;
int a=m/10;
if(t<=a){
if(60*t<s){
cout<<"No\n"<<60*t;
}else{
cout<<"Yes\n"<<ud(s,60);
}
return 0;
}
int h=t;
t-=a;
int d=a*60;
m-=a*10;
while(t){
if(0<=m&&m<=1){
if(t>=7){
t-=7;
d+=120;
if(d>=s)break;
continue;
}else{
goto l;
}
}
if(2<=m&&m<=5){
if(t>=3){
t-=3;
d+=60;
m-=2;
if(d>=s)break;
continue;
}else{
goto l;
}
}
if(6<=m&&m<=9){
if(t>=2){
t-=2;
d+=60;
m-=6;
if(d>=s)break;
continue;
}else{
goto l;
}
}
l:
int k=min(t,ud(s-d,17));
d+=k*17;
t-=k;
break;
}
if(d>=s){
cout<<"Yes\n"<<h-t;
}else{
cout<<"No\n"<<d;
}
return 0;
}