a=input().split()
s=int(a[0])
v=int(a[1])
if s%v!=0:
t=s
else:
t=s
t+=10
if t<60*8:
if t%60==0:
h=8-t
print('0'+str(h)+':00')
elif 60-t%60<10:
h=7-t
minu=60-t%60
print('0'+str(h)+':0'+str(minu))
else:
h=7-t
minu=60-t%60
print('0'+str(h)+':'+str(minu))
else:
if t%60==0:
h=24+8-t
print(str(h)+':00')
else:
h=23+8-t
minu=60-t%60
print(str(h)+':'+str(minu))
Java:
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int s=sc.nextInt();
int v=sc.nextInt();
double t1=(int)Math.ceil((double)s/v);
int totalNeedTime=(int) (10+t1);
int targetMinute=8*60;
int startMinute=targetMinute-totalNeedTime;
if (startMinute<0){
startMinute+=24*60;
}
int finalHour=startMinute/60;
int finalMinute=startMinute%60;
System.out.printf("%02d:%02d",finalHour,finalMinute);
sc.close();
}
}