#include <stdio.h>
#include <string.h>

#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef long long ll;

const int dy[] = {1,0,-1,0};
const int dx[] = {0,1,0,-1};
const char dir[] = "URDL";

int d[100];
char s[105];
int vx[105], vy[105];
int ix, iy;
int main() {
	int a,b;
	while(scanf("%d%d", &a, &b) == 2) {
		scanf("%s",s);
		ll y=0,x=0;
		int n = strlen(s);
		REP(i,n) {
			d[i] = strchr(dir, s[i]) - dir;
		}
		ix = 0;
		iy = 0;
		vx[ix++] = 0;
		vy[iy++] = 0;
		REP(i,n) {
			y += dy[d[i]];
			x += dx[d[i]];
			vy[iy++] = y;
			vx[ix++] = x;
		}
		ll Y = y;
		ll X = x;
		int ok = 0;
		REP(i,n) {
			REP(j,n) {
				ll yy = vy[j];
				ll xx = vx[j];
				ll y = b-yy;
				ll x = a-xx;
				if (Y && y % Y == 0 && y/Y>=0) {
					if (X*(y/Y) == x) {
						ok = 1;
					}
				}
				if (Y == 0 && y == 0) {
					if (x == 0 || (X && x % X == 0 && x/X>=0)) {
						ok = 1;
					}
				}
			}
		}
		printf("%s\n",ok?"Yes":"No");
	}
}

#include <stdio.h>
#include <stdbool.h>

int a, b;
int dx, dy;
char str[110];

int abs(int a){
	return a >= 0 ? a : -a;
}

int sign(int x){
	if (x > 0)
		return 1;
	else if (x == 0)
		return 0;
	else
		return -1;
}

bool check(int x, int y){
	int xdiff = a - x;
	int ydiff = b - y;

	if (x == a && y == b)
		return true;

	if (a != x && dx == 0)
		return false;
	if (b != y && dy == 0)
		return false;

	if (sign(xdiff) * sign(dx) < 0 || sign(ydiff) * sign(dy) < 0)
		return false;

	if (dx == 0)
		return abs(ydiff) % abs(dy) == 0;
	else if (dy == 0)
		return abs(xdiff) % abs(dx) == 0;
	else
		return
			abs(ydiff) % abs(dy) == 0 &&
			abs(xdiff) % abs(dx) == 0 &&
			((long long int)xdiff) * dy == ((long long int)ydiff) * dx;
}

int main(void){
	int i, j;

	scanf("%d %d", &a, &b);
	scanf("%s", str);

	for (i = 0; str[i]; i++){
		if (str[i] == 'U')
			dy++;
		else if (str[i] == 'D')
			dy--;
		else if (str[i] == 'R')
			dx++;
		else if (str[i] == 'L')
			dx--;
	}

	int x = 0, y = 0;
	bool works = check(0,0);

	for (i = 0; !works && str[i]; i++){
		if (str[i] == 'U')
			y++;
		else if (str[i] == 'D')
			y--;
		else if (str[i] == 'R')
			x++;
		else if (str[i] == 'L')
			x--;
		works = check(x,y);
	}

	printf("%s\n", works ? "Yes" : "No");

	return 0;
}

#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(){
    int sx=0,sy=0,p=1,a,b,i,num_len,dx,dy;
    char s[110];
    int pos_x[110];
    int pos_y[110];
    scanf("%d %d %s",&a,&b,s);
    pos_x[0]=pos_y[0]=0;
    num_len=strlen(s);
    for(i=0;i<num_len;i++){
        switch(s[i]){
        case 'U':
            sy++;
            break;
        case 'D':
            sy--;
            break;
        case 'R':
            sx++;
            break;
        case 'L':
            sx--;
            break;
        default: ;
        }
        pos_x[i+1]=sx;
        pos_y[i+1]=sy;
    }
    dx=pos_x[num_len];
    dy=pos_y[num_len];
    for(i=0;i<=num_len;i++){
        if(dx && dy){
            if((float)(a-pos_x[i])/dx==(float)(b-pos_y[i])/dy && (a-pos_x[i])%dx==0 && ((dx>0 && (a-pos_x[i])>=0)||(dx<0 && (a-pos_x[i])<=0))) {printf("Yes"); return 0;}
        }
        else if(dx){
            if(b-pos_y[i]==0 && (a-pos_x[i])%dx==0 && ((dx>0 && (a-pos_x[i])>=0)||(dx<0 && (a-pos_x[i])<=0))) {printf("Yes"); return 0;}
        }else if(dy){
            if(a-pos_x[i]==0 && (b-pos_y[i])%dy==0 && ((dy>0 && (b-pos_y[i])>=0)||(dy<0 && (b-pos_y[i])<=0))) {printf("Yes"); return 0;}
        }else{
            if(a==pos_x[i] && b==pos_y[i]) {printf("Yes"); return 0;}
        }
    }
    printf("No");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define For(i,n) for(i=0;i<n;i++)
#define MAX(x,y) x>y?x:y
#define MAXN 111

int mov[MAXN][2];

main()
{
    int i, j, flag = 1;
    int k, a, b;
    int x, y, sx = 0, sy = 0;
    char s[111];
    scanf("%d%d%s",&x,&y,s);
    mov[0][0] = mov[0][1] = 0;
    for(i = 0; s[i]; i++)
    {
        mov[i+1][0] = (s[i]=='U'||s[i]=='D')?0:s[i]=='R'?1:-1;
        mov[i+1][1] = (s[i]=='R'||s[i]=='L')?0:s[i]=='U'?1:-1;
        sx += mov[i+1][0];
        sy += mov[i+1][1];
    }
    For(i,strlen(s)){
        x -= mov[i][0];
        y -= mov[i][1];
        //printf("%d %d\n",x,y);
        if(sx==0&&sy==0) k = 1;
        else if(sx!=0)  k = x/sx;
        else k = y/sy;
        if(sx*k==x&&sy*k==y&&k>=0)
        {
            printf("Yes\n");
            flag = 0; break;
        }
    }
    if(flag) printf("No\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,fx=0,fy=0,i,j,k,l,mx,ny,ix,iy,c=0,n;
    char s1[1000];
    scanf("%d%d",&a,&b);
    scanf("%s",s1);
    l=strlen(s1);
    if(a==0 && b==0)
    {
        printf("Yes");
        return(0);
    }
    for(i=0;i<l;i++)
    {
        if(s1[i]=='U')
            fy=fy+1;
        else if(s1[i]=='D')
            fy-=1;
        else if(s1[i]=='R')
            fx+=1;
        else if(s1[i]=='L')
            fx-=1;
    }
    //printf("%d %d\n",fx,fy);
    if(fx!=0 || fy!=0)
    {
        if(fx!=0)
            mx=(a-fx)/fx;
        if(fy!=0)
            ny=(b-fy)/fy;
        if(fx==0 && fy!=0)
            mx=ny;
        else if(fy==0 && fx!=0)
            ny=mx;
        //printf("%d %d\n",mx,ny);
        if(mx<0 || ny<0)
        {
            printf("No");
            return(0);
        }
        else
        {
            c=0;
            n=(mx<ny)?mx:ny;
            ix=fx+n*fx;
            iy=fy+n*fy;
            for(i=0;i<l;i++)
            {
                if(ix==a && iy==b)
                {
                    c++;
                    printf("Yes");
                    return(0);
                }
                if (s1[i]=='U')
                iy=fy+1;
                else if(s1[i]=='D')
                iy-=1;
                else if(s1[i]=='R')
                ix+=1;
                else if(s1[i]=='L')
                ix-=1;

            }
            if(ix==a && iy==b)
                {
                    c++;
                    printf("Yes");
                    return(0);
                }
            if(c==0)
            {
                printf("No");
                return(0);
            }
        }
    }
    else
    {
        c=0;
        if(fx==0 && fy==0)
            {
                c=0;
                for(i=0;i<l;i++)
                {
                    if(fx==a && fy==b)
                    {
                        printf("Yes");
                        c++;
                        return(0);
                    }
                    if(s1[i]=='U')
                    fy=fy+1;
                    else if(s1[i]=='D')
                    fy-=1;
                    else if(s1[i]=='R')
                    fx+=1;
                    else if(s1[i]=='L')
                    fx-=1;
                }
            if(c==0)
            {
                printf("No");
                return(0);
            }
            }
    }
}

#include <stdio.h>
#include <string.h>

#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef long long ll;

const int dy[] = {1,0,-1,0};
const int dx[] = {0,1,0,-1};
const char dir[] = "URDL";

int d[100];
char s[105];
int vx[105], vy[105];
int ix, iy;
int main() {
	int a,b;
	while(scanf("%d%d", &a, &b) == 2) {
		scanf("%s",s);
		ll y=0,x=0;
		int n = strlen(s);
		REP(i,n) {
			d[i] = strchr(dir, s[i]) - dir;
		}
		ix = 0;
		iy = 0;
		vx[ix++] = 0;
		vy[iy++] = 0;
		REP(i,n) {
			y += dy[d[i]];
			x += dx[d[i]];
			vy[iy++] = y;
			vx[ix++] = x;
		}
		ll Y = y;
		ll X = x;
		int ok = 0;
		REP(i,n) {
			REP(j,n) {
				ll yy = vy[j];
				ll xx = vx[j];
				ll y = b-yy;
				ll x = a-xx;
				if (Y && y % Y == 0) {
					if (X*(y/Y) == x) {
						ok = 1;
					}
				}
				if (Y == 0 && y == 0) {
					if (x == 0 || (X && x % X == 0)) {
						ok = 1;
					}
				}
			}
		}
		printf("%s\n",ok?"Yes":"No");
	}
}

#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(){
    int sx=0,sy=0,p=1,a,b,i,num_len,dx,dy;
    char s[101];
    int pos_x[101];
    int pos_y[101];
    scanf("%d %d %s",&a,&b,s);
    pos_x[0]=pos_y[0]=0;
    num_len=strlen(s);
    for(i=0;i<num_len;i++){
        switch(s[i]){
        case 'U':
            sy++;
            break;
        case 'D':
            sy--;
            break;
        case 'R':
            sx++;
            break;
        case 'L':
            sx--;
            break;
        default: ;
        }
        pos_x[i+1]=sx;
        pos_y[i+1]=sy;
    }
    dx=pos_x[num_len];
    dy=pos_y[num_len];
    for(i=0;i<=num_len;i++){
        if((a-pos_x[i])*dy==(b-pos_y[i])*dx) {printf("Yes"); return 0;}
    }
    printf("No");
    return 0;
}

#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(){
    int sx=0,sy=0,p=1,a,b,i,num_len,dx,dy;
    char s[101];
    int pos_x[101];
    int pos_y[101];
    scanf("%d %d %s",&a,&b,s);
    pos_x[0]=pos_y[0]=0;
    num_len=strlen(s);
    for(i=0;i<num_len;i++){
        switch(s[i]){
        case 'U':
            sy++;
            break;
        case 'D':
            sy--;
            break;
        case 'R':
            sx++;
            break;
        case 'L':
            sx--;
            break;
        default: ;
        }
        pos_x[i+1]=sx;
        pos_y[i+1]=sy;
    }
    dx=pos_x[num_len];
    dy=pos_y[num_len];
    for(i=0;i<=num_len;i++){
        if(dx && dy){
            if((a-pos_x[i])*dy==(b-pos_y[i])*dx) {printf("Yes"); return 0;}
        }
        else if(dx){
            if(b-pos_y[i]==0 && (a-pos_x[i])%dx==0) {printf("Yes"); return 0;}
        }else{
            if(a-pos_x[i]==0 && (b-pos_y[i])%dy==0) {printf("Yes"); return 0;}
        }
    }
    printf("No");
    return 0;
}

#include <stdio.h>
#include <malloc.h>
#include <string.h>

int main(){
    int sx=0,sy=0,p=1,a,b,i,num_len,dx,dy;
    char s[110];
    int pos_x[110];
    int pos_y[110];
    scanf("%d %d %s",&a,&b,s);
    pos_x[0]=pos_y[0]=0;
    num_len=strlen(s);
    for(i=0;i<num_len;i++){
        switch(s[i]){
        case 'U':
            sy++;
            break;
        case 'D':
            sy--;
            break;
        case 'R':
            sx++;
            break;
        case 'L':
            sx--;
            break;
        default: ;
        }
        pos_x[i+1]=sx;
        pos_y[i+1]=sy;
    }
    dx=pos_x[num_len];
    dy=pos_y[num_len];
    for(i=0;i<=num_len;i++){
        if(dx && dy){
            if((float)(a-pos_x[i])/dx==(float)(b-pos_y[i])/dy && ((dx>0 && (a-pos_x[i])>=0)||(dx<0 && (a-pos_x[i])<=0))) {printf("Yes"); return 0;}
        }
        else if(dx){
            if(b-pos_y[i]==0 && (a-pos_x[i])%dx==0 && ((dx>0 && (a-pos_x[i])>=0)||(dx<0 && (a-pos_x[i])<=0))) {printf("Yes"); return 0;}
        }else if(dy){
            if(a-pos_x[i]==0 && (b-pos_y[i])%dy==0 && ((dy>0 && (b-pos_y[i])>=0)||(dy<0 && (b-pos_y[i])<=0))) {printf("Yes"); return 0;}
        }else{
            if(a==pos_x[i] && b==pos_y[i]) {printf("Yes"); return 0;}
        }
    }
    printf("No");
    return 0;
}

#include <stdio.h>
#include <stdbool.h>

int a, b;
int dx, dy;
char str[110];

int abs(int a){
	return a >= 0 ? a : -a;
}

int sign(int x){
	if (x > 0)
		return 1;
	else if (x == 0)
		return 0;
	else
		return -1;
}

bool check(int x, int y){
	int xdiff = a - x;
	int ydiff = b - y;

	if (x == a && y == b)
		return true;

	if (a != x && dx == 0)
		return false;
	if (b != y && dy == 0)
		return false;

	if (sign(xdiff) * sign(dx) < 0 || sign(ydiff) * sign(dy) < 0)
		return false;

	if (dx == 0)
		return abs(ydiff) % abs(dy) == 0;
	else if (dy == 0)
		return abs(xdiff) % abs(dx) == 0;
	else
		return ((unsigned long long int)xdiff) * dy / dx == ydiff;
}

int main(void){
	int i, j;

	scanf("%d %d", &a, &b);
	scanf("%s", str);

	for (i = 0; str[i]; i++){
		if (str[i] == 'U')
			dy++;
		else if (str[i] == 'D')
			dy--;
		else if (str[i] == 'R')
			dx++;
		else if (str[i] == 'L')
			dx--;
	}

	int x = 0, y = 0;
	bool works = check(0,0);

	for (i = 0; !works && str[i]; i++){
		if (str[i] == 'U')
			y++;
		else if (str[i] == 'D')
			y--;
		else if (str[i] == 'R')
			x++;
		else if (str[i] == 'L')
			x--;
		works = check(x,y);
	}

	printf("%s\n", works ? "Yes" : "No");

	return 0;
}

#include <stdio.h>
#include <stdbool.h>

int a, b;
int dx, dy;
char str[110];

int abs(int a){
	return a >= 0 ? a : -a;
}

int sign(int x){
	if (x > 0)
		return 1;
	else if (x == 0)
		return 0;
	else
		return -1;
}

bool check(int x, int y){
	int xdiff = a - x;
	int ydiff = b - y;

	if (x == a && y == b)
		return true;

	if (a != x && dx == 0)
		return false;
	if (b != y && dy == 0)
		return false;

	if (sign(xdiff) * sign(dx) < 0 || sign(ydiff) * sign(dy) < 0)
		return false;

	if (dx == 0)
		return abs(ydiff) % abs(dy) == 0;
	else if (dy == 0)
		return abs(xdiff) % abs(dx) == 0;
	else
		return ((long long int)xdiff) * dy / dx == ydiff;
}

int main(void){
	int i, j;

	scanf("%d %d", &a, &b);
	scanf("%s", str);

	for (i = 0; str[i]; i++){
		if (str[i] == 'U')
			dy++;
		else if (str[i] == 'D')
			dy--;
		else if (str[i] == 'R')
			dx++;
		else if (str[i] == 'L')
			dx--;
	}

	int x = 0, y = 0;
	bool works = check(0,0);

	for (i = 0; !works && str[i]; i++){
		if (str[i] == 'U')
			y++;
		else if (str[i] == 'D')
			y--;
		else if (str[i] == 'R')
			x++;
		else if (str[i] == 'L')
			x--;
		works = check(x,y);
	}

	printf("%s\n", works ? "Yes" : "No");

	return 0;
}

#include <stdio.h>
#include <stdbool.h>

int a, b;
int dx, dy;
char str[110];

int abs(int a){
	return a >= 0 ? a : -a;
}

int sign(int x){
	if (x > 0)
		return 1;
	else if (x == 0)
		return 0;
	else
		return -1;
}

bool check(int x, int y){
	int xdiff = a - x;
	int ydiff = b - y;

	if (x == a && y == b)
		return true;

	if (a != x && dx == 0)
		return false;
	if (b != y && dy == 0)
		return false;

	if (sign(xdiff) * sign(dx) < 0 || sign(ydiff) * sign(dy) < 0)
		return false;

	if (dx == 0)
		return abs(ydiff) % abs(dy) == 0;
	else if (dy == 0)
		return abs(xdiff) % abs(dx) == 0;
	else
		return xdiff * dy / dx == ydiff;
}

int main(void){
	int i, j;

	scanf("%d %d", &a, &b);
	scanf("%s", str);

	for (i = 0; str[i]; i++){
		if (str[i] == 'U')
			dy++;
		else if (str[i] == 'D')
			dy--;
		else if (str[i] == 'R')
			dx++;
		else if (str[i] == 'L')
			dx--;
	}

	int x = 0, y = 0;
	bool works = check(0,0);

	for (i = 0; !works && str[i]; i++){
		if (str[i] == 'U')
			y++;
		else if (str[i] == 'D')
			y--;
		else if (str[i] == 'R')
			x++;
		else if (str[i] == 'L')
			x--;
		works = check(x,y);
	}

	printf("%s\n", works ? "Yes" : "No");

	return 0;
}

#include <stdio.h>
#include <stdbool.h>

int a, b;
int dx, dy;
char str[110];

int abs(int a){
	return a >= 0 ? a : -a;
}

bool check(int x, int y){
	int xdiff = a - x;
	int ydiff = b - y;

	if (x == a && y == b)
		return true;

	if (a != x && dx == 0)
		return false;
	if (b != y && dy == 0)
		return false;

	if (xdiff * dx < 0 || ydiff * dy < 0)
		return false;

	if (dx == 0)
		return abs(ydiff) % abs(dy) == 0;
	else if (dy == 0)
		return abs(xdiff) % abs(dx) == 0;
	else
		return a * dy / dx == b;
}

int main(void){
	int i, j;

	scanf("%d %d", &a, &b);
	scanf("%s", str);

	for (i = 0; str[i]; i++){
		if (str[i] == 'U')
			dy++;
		else if (str[i] == 'D')
			dy--;
		else if (str[i] == 'R')
			dx++;
		else if (str[i] == 'L')
			dx--;
	}

	int x = 0, y = 0;
	bool works = check(0,0);

	for (i = 0; !works && str[i]; i++){
		if (str[i] == 'U')
			y++;
		else if (str[i] == 'D')
			y--;
		else if (str[i] == 'R')
			x++;
		else if (str[i] == 'L')
			x--;
		works = check(x,y);
	}

	printf("%s\n", works ? "Yes" : "No");

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define For(i,n) for(i=0;i<n;i++)
#define MAX(x,y) x>y?x:y
#define MAXN 111

int mov[MAXN][2];

main()
{
    int i, j, flag = 1;
    int k, a, b;
    int x, y, sx = 0, sy = 0;
    char s[111];
    scanf("%d%d%s",&a,&b,s);
    mov[0][0] = mov[0][1] = 0;
    for(i = 0; s[i]; i++)
    {
        mov[i+1][0] = (s[i]=='U'||s[i]=='D')?0:s[i]=='R'?1:-1;
        mov[i+1][1] = (s[i]=='R'||s[i]=='L')?0:s[i]=='U'?1:-1;
        sx += mov[i+1][0];
        sy += mov[i+1][1];
    }
    For(i,strlen(s)){
        x = a - mov[i][0];
        y = b - mov[i][1];
        if(sx==0&&sy==0) k = 1;
        else if(sx!=0)  k = x/sx;
        else k = y/sy;
        if(sx*k==x&&sy*k==y)
        {
            printf("Yes\n");
            flag = 0; break;
        }
    }
    if(flag) printf("No\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define For(i,n) for(i=0;i<n;i++)
#define MAX(x,y) x>y?x:y
#define MAXN 10001

int mov[MAXN][2];

main()
{
    int i, j, flag = 1;
    int k, a, b;
    int x, y, sx = 0, sy = 0;
    char s[111];
    scanf("%d%d%s",&a,&b,s);
    mov[0][0] = mov[0][1] = 0;
    for(i = 0; s[i]; i++)
    {
        mov[i+1][0] = (s[i]=='U'||s[i]=='D')?0:s[i]=='R'?1:-1;
        mov[i+1][1] = (s[i]=='R'||s[i]=='L')?0:s[i]=='U'?1:-1;
        sx += mov[i+1][0];
        sy += mov[i+1][1];
    }
    For(i,strlen(s)){
        x = a - mov[i][0];
        y = b - mov[i][1];
        if(sx) k = x/sx;
        else if(sy) k = y/sy;
        else k = 1;
        if(sx*k==x&&sy*k==y)
        {
            printf("YES\n");
            flag = 0; break;
        }
    }
    if(flag) printf("NO\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define For(i,n) for(i=0;i<n;i++)
#define MAX(x,y) x>y?x:y
#define MAXN 111

int mov[MAXN][2];

main()
{
    int i, j, flag = 1;
    int k, a, b;
    int x, y, sx = 0, sy = 0;
    char s[111];
    scanf("%d%d%s",&x,&y,s);
    mov[0][0] = mov[0][1] = 0;
    for(i = 0; s[i]; i++)
    {
        mov[i+1][0] = (s[i]=='U'||s[i]=='D')?0:s[i]=='R'?1:-1;
        mov[i+1][1] = (s[i]=='R'||s[i]=='L')?0:s[i]=='U'?1:-1;
        sx += mov[i+1][0];
        sy += mov[i+1][1];
    }
    For(i,strlen(s)){
        x -= mov[i][0];
        y -= mov[i][1];
        if(sx==0&&sy==0) k = 1;
        else if(sx!=0)  k = x/sx;
        else k = y/sy;
        if(sx*k==x&&sy*k==y&&k>0)
        {
            printf("Yes\n");
            flag = 0; break;
        }
    }
    if(flag) printf("No\n");
    return 0;
}


#include<stdio.h>
char s1[30],s2[30];
long long change(char *s)
{
	long long sum=0,i;
	for(i=0;i<strlen(s);i++)
	{
		sum=sum*10+s[i]-'0';
	}
	return sum;
}
long long f(int a,int b)
{
	long long sum=1;
	int i;
	for(i=1;i<=b;i++)
	{
		sum*=a;
	}
	return sum;
}
int main(void)
{
	long long l,r,i;
	scanf("%s%s",s1,s2);
	long long x1,x2,x3;
	int len=strlen(s2);
	x1=change(s1);
	x2=change(s2);
	x3=5*f(10,len-1)-1;
	if(x3<=x2&&x3>=x1) printf("%I64d\n",x3*(f(10,len)-1-x3));
	else if(x3<x1) printf("%I64d\n",x1*(f(10,len)-1-x1));
	else printf("%I64d\n",x2*(f(10,len)-1-x2));
	return 0;
}

#include<stdio.h>
int main()
{long long int l,r,t,n,x=0;
scanf("%I64d %I64d",&r,&l);
n=l;
while(n!=0)
{n=n/10;
x=x*10+9;
}

if(l<=x/2)
printf("%I64d",l*(x-l));
else if(l>x/2&&r<x/2)
printf("%I64d",x/2*(x-x/2));
else
printf("%I64d",r*(x-r));

return 0;
}

#include<stdio.h>
long long find_max(long long low,long long high,long long power)
{
    if(low>high)
        return 0;
    if((power/2>=low&&power/2<=high)||(power/2-1>=low&&power/2-1<=high))
        return (power/2*(power/2-1));
    if(low>power/2)
        return (low*(power-1-low));
    return (high*(power-1-high));
}
main()
{
 long long l,r,max=0;
 scanf("%I64d%I64d",&l,&r);
 int low_digit=0,high_digit=0;
 long long no=l,power=1;
 while(no!=0)
 {
    low_digit++;
    no/=10;
    power*=10;
 }
 no=r;
 while(no!=0)
 {
     high_digit++;
     no/=10;
 }
 long long current_max,low=l,high=power-1;
 while(low_digit<high_digit)
 {
     current_max=find_max(low,high,power);
     if(max<current_max)
        max=current_max;
     low=power;
     high=power*10-1;
     power=power*10;
     low_digit++;
 }
 current_max=find_max(low,r,power);
 if(current_max>max)
    max=current_max;
 printf("%I64d",max);
 return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long

ll pw[30];

ll ref(ll a){
  int i, now=0;
  ll res = 0;

  while(a){
    res += pw[now] * (9 - (a%10));
    now++; a/=10;
  }

  return res;
}

int main(){
  int i,j,k,l,m,n;
  int a,b;
  ll res, tmp, go;

  pw[0] = 1;
  REP(i,1,30) pw[i] = pw[i-1]*10;

  while(scanf("%d%d",&a,&b)==2){
    res = 0;
    REP(i,1,15){
      go = pw[i] / 2;
      if(go < a) go = a;
      if(go > b) go = b;
      tmp = go * ref(go);
      if(res < tmp) res = tmp;
    }
    printf("%I64d\n",res);
  }

  return 0;
}

#include<stdio.h>
__int64 i,j=1,l,r,a=0,b,c=0,k;
__int64 weight(int n1,int n)
{
    b=n;
    while(n!=0)
    {
        n/=10;
        a=a*10+9;
        c++;
    }
    for(i=1;i<=c;i++)
      j*=10;
    k=j/2;
    if(k>=n1 && k<=b)
        return((a-k)*k);
    else if(k>b)
        return((a-b)*b);
        else
            return((a-n1)*n1);
}
int main()
{
    scanf("%d%d",&l,&r);
    printf("%I64d",weight(l,r));
    return(0);
}

#include <stdio.h>

long long max(long long a, long long b)
{
     if (a > b) {
	  return a;
     } else {
	  return b;
     }
}

long long min(long long a, long long b)
{
     if (a < b) {
	  return a;
     } else {
	  return b;
     }
}

long long reverse(long long n)
{
     long long r = 0, d = 1;
     int i;

     while (n) {
	  r += (9 - n % 10) * d;
	  n /= 10;
	  d *= 10;
     }

     return r;
}

int main()
{
     int l, r, c, i;
     long long d = 1;

     scanf("%d %d", &l, &r);

     c = r;

     while (c) {
	  c /= 10;
	  d *= 10;
     }

     d /= 10;

     l = max(l, d);

     if (r < d * 5) {
	  printf("%I64d\n", (long long)r * reverse(r));
     } else if (l > d * 5) {
	  printf("%I64d\n", (long long)l * reverse(l));
     } else {
	  printf("%I64d\n", (long long)d * 5 * reverse(d * 5));
     }

     return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
 long long int l,r,i,y,max,n,x,j,m;
  scanf("%I64d%I64d",&l,&r);
  max=0;

  for(i=l;i<=r;i++)
  { x=log10(i);
      n=pow(10,(x+1))-1-i;

     if(n*i>max)
       max=n*i;
       }
     printf("%I64d",max);
     return  0;
     }

#include<stdio.h>
#include<math.h>
int main()
{
 long long int l,r,i,y,max,n,x,j,m;
  scanf("%I64d%I64d",&l,&r);
  max=0;

  for(i=l;i<=r;i++)
  { x=log10(i);
  if(i%10==0)
  n=pow(10,(x+1))-i;
  else
      n=pow(10,(x+1))-1-i;

     if(n*i>max)
       max=n*i;
       }
     printf("%I64d",max);
     return  0;
     }

#include<stdio.h>
int main()
{
  long int l,r,i,y,max,n,x,j,m;
  scanf("%ld%ld",&l,&r);
  max=0;

  for(i=l;i<=r;i++)
  { n=0;
    j=1;
    m=i;

     while(m>0)
     {  y=m%10;
        x=9-y;
        n=n+j*x;
        m=m/10;
        j=j*10;
        }
     if(n*i>max)
       max=n*i;
       }
     printf("%ld",max);
     return  0;
     }

#include<stdio.h>
int main()
{long long int l,r,t,n,x=0;
scanf("%I64d %I64d",&r,&l);
n=l;
while(n!=0)
{n=n/10;
x=x*10+9;
}

if(l<x/2)
printf("%I64d",l*(x-l));
else if(l>x/2&&r<x/2)
printf("%I64d",x/2*(x-x/2));
else
printf("%I64d",r*(x-r));

return 0;
}

#include<stdio.h>
__int64 i,j=1,l,r,a=0,b,c=0,k;
__int64 weight(int n)
{
    b=n;
    while(n!=0)
    {
        n/=10;
        a=a*10+9;
        c++;
    }
    for(i=1;i<=c;i++)
      j*=10;
    k=j/2;
    if(b>=k)
        return((a-k)*k);
    else
        return((a-b)*b);
}
int main()
{
    scanf("%d%d",&l,&r);
    printf("%I64d",weight(r));
    return(0);
}

#include <stdio.h>

long long max(long long a, long long b)
{
     if (a > b) {
	  return a;
     } else {
	  return b;
     }
}

long long min(long long a, long long b)
{
     if (a < b) {
	  return a;
     } else {
	  return b;
     }
}

int reverse(int n)
{
     int r = 0, d = 1, i;

     while (n) {
	  r += (9 - n % 10) * d;
	  n /= 10;
	  d *= 10;
     }

     return r;
}

int main()
{
     int l, r, c, i;
     long long d = 1;

     scanf("%d %d", &l, &r);

     c = r;

     while (c) {
	  c /= 10;
	  d *= 10;
     }

     d /= 10;

     l = max(l, d);

     if (r < d * 5) {
	  printf("%I64d\n", (long long)r * reverse(r));
     } else if (l > d * 5) {
	  printf("%I64d\n", (long long)l * reverse(l));
     } else {
	  printf("%I64d\n", (long long)d * 5 * reverse(d * 5));
     }

     return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
 long long int l,r,i,y,max,n,x,j,m;
  scanf("%I64d%I64d",&l,&r);
  max=0;

  for(i=l;i<=r;i++)
  { x=log10(i);
  if(i==10)
  n=89;
  else
      n=pow(10,(x+1))-1-i;

     if(n*i>max)
       max=n*i;
       }
     printf("%I64d",max);
     return  0;
     }


#include<stdio.h>
int main(void){
int count,mm,hh,x;
scanf("%d",&x);
scanf("%d %d",&hh,&mm);
for(count=0;hh%10!=7&&mm%10!=7;){
    mm=mm-x;
    count++;
    if(mm<0) {mm=60+mm;
    hh--;}
    if(hh<0) {hh=24+hh;}
}
printf("%d",count);
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdbool.h>

#define max(A, B) ((A > B) ? A : B)
#define min(A, B) ((A > B) ? B : A)
#define INF 999999

int x;
int h, m;

int main()
{
    int ans;
    int y;

    scanf("%d", &x);
    scanf("%d%d", &h, &m);
    if (h == 7 || h == 17 || m % 10 == 7)
        printf("0");
    else{
        if (h > 17) {
            y = 0;
            while (1) {
                if (m - x < 0) {
                    h--;
                    m += 60;
                }
                m -= x;
                y++;
                if (m % 10 == 7 || h == 17) {
                    ans = y;
                    break;
                }
            }
        }else if (h < 7) {
            y = 0;
            h += 24;
            while (1) {
                if (m - x < 0) {
                    h--;
                    m += 60;
                }
                m -= x;
                y++;
                if (m % 10 == 7 || h == 17) {
                    ans = y;
                    break;
                }
            }
        }else{
            y = 0;
            while (1) {
                if (m - x < 0) {
                    h--;
                    m += 60;
                }
                m -= x;
                y++;
                if (m % 10 == 7 || h == 7) {
                    ans = y;
                    break;
                }
            }
        }
        printf("%d", ans);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{  int n,hh,mm,c=0;
scanf("%d%d%d",&n,&hh,&mm);

while(1)

{if(hh%10==7||mm%10==7){
   break;

}

else{
    if(mm-n>=0){
            mm=mm-n;
            c++;

    }
    else
    {
        mm=60+mm-n;
        c++;
       if(hh-1>=0){
        hh=hh-1;
       }
       else
       { hh=23;

       }
    }
}

}
printf("%d",c);

    return 0;}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{  int n,hh,mm,c=0,d;
scanf("%d%d%d",&n,&hh,&mm);

while(1)

{if(hh%10==7||mm%10==7){
   break;

}

else{
    if(mm-n>=0){
            mm=mm-n;
            c++;

    }
    else
    {
        mm=60+mm-n;
        c++;
       if(hh-1>=0){
        hh=hh-1;
       }
       else
       { hh=23;

       }
    }
}

}
printf("%d",c);

    return 0;}

#include<stdio.h>

int seven(int x,int y)
{
	int p;
	if(x==7||y==7||(x/10)==7||(y/10)==7)
		return 1;
	x=x%10;
	y=y%10;
	if(x==7||y==7)
		return 1;
	else
		return 0;
}

int main()
{
	int x,hh,mm,i=0,p=0;
	scanf("%d%d%d",&x,&hh,&mm);
	for(i=0;i<10000;i++)
	{
		if(seven(hh,mm)==1)
		{
			break;
		}
		if(x<=mm)
		{
			mm=mm-x;
		}
		else
		{
			if(x>mm)
			{
				mm=60+mm-x;
				if(hh==0)
					hh=23;
				else
					hh=hh-1;
			}
		}
		p++;
	}
	printf("%d\n",p);
	return 0;
}

#include<stdio.h>
int F(int x,int n,int m)
{
	int i;
    for(i=0;;i++)
	{
		if(n%10==7||m%10==7)
		{
			printf("%d\n",i);
			break;
		}
		else
		{
			m-=x;
			if(m<0)
			{
				m+=60;
				n--;
			}
			if(n<0)
				n+=24;
		}
	}
}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	F(a,b,c);
	return 0;
}

#include<stdio.h>
#include<stdbool.h>
bool ThereIsSeven(int num)
{
    while (num!=0)
    {
        if (num%10==7)
            return true;
        num/=10;
    }
    return false;

}
int main()
{
    int x, hh, mm;
    int count=0;
    scanf("%d", &x);
    scanf("%d %d", &hh,&mm);
    while (ThereIsSeven(hh)==false && ThereIsSeven(mm)==false)
   {
       mm=mm-x;
       if (mm<0)
       {
           mm=mm+60;
           hh=hh-1;
           hh=(hh+24)%24;
       }
       count++;
   }
   printf("%d", count);
    return 0;

}

#include <stdio.h>

int main() {
    int x;
    scanf("%d",&x);
    int hh,mm,tempMM,count,tempHH;
    scanf("%d %d",&hh,&mm);

    if((hh == 17)||(hh == 7)||(mm % 10 == 7))
        printf("0\n");
    else{
        tempMM = mm , tempHH = hh,count = 0;
        while(1){
            if((tempMM % 10 == 7) || (tempHH%10) == 7)
               break;
             if((tempMM - x) < 0){
                 if(tempHH == 0)
                    tempHH = 23;
                else
                    tempHH--;
             }
//                tempHH--;
             if((tempMM - x)<0){
                 tempMM = 60 + tempMM - x ;
             }else{
                 tempMM = tempMM - x;
             }
//            tempMM = tempMM - x;
            count++;
        }
        printf("%d\n",count);
    }

	return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int contains(int m){
    int r;
    while(m > 0){
        r = m % 10;
        if(r == 7)
            return 0;
        m = m /10;
    }
    return 1;

}
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    int t;
    scanf("%d",&t);
    int m,n;
    scanf("%d%d",&m,&n);
    long long int c = 0;
    while(contains(m) && contains(n)){

        n = n - t;

        c++;
        if(n < 0){
            m = m - 1;
            if(m == -1)
                m = 23;
            n = n + 60;
        }

    }
    printf("%lld\n",c);
    return 0;
}

#include<stdio.h>

int check(int h,int m)
{
	int count=0;
	while(h>0)
	{
		if(h%10==7)
		{
			count++;
		}
		h=h/10;
	}
	while(m>0)
	{
		if(m%10==7)
		{
			count++;
		}
		m=m/10;
	}
	return count;
}
int main()
{
	int x;
	scanf("%d",&x);
	int h,m,count1=0,count=0,i;
	scanf("%d %d",&h,&m);
	while(1)
	{
		count=check(h,m);
		if(count>0)
		{
			printf("%d\n",count1);
			break;
		}
		else
		{
			m=m-x;
			if(m<0)
			{
				h--;
				if(h<0)
				{
					h=h+24;
				}
				m=60+m;
			}
			h=h%24;
			m=m%60;
			count1++;
		}
	}
	return 0;
}

#include <stdio.h>
#include <stdbool.h>

// - WRONG in isluck
// - timeout
bool isluck(int h, int m) {
    return h % 10 == 7 || m % 10 == 7;
}
int luck(int h, int m, int x) {
    int cnt = 0;
    for (cnt = 0; !isluck(h, m); cnt++) {
        m -= x;
        if (m < 0) {
            m += 60;
            h -= 1;
            if (h < 0) {
                h += 24;
            }
        }
    }
    // printf("%d %d\n", h, m);
    return cnt;
}
int test();
int main() {
#if 1
    int x;
    int h, m;
    scanf("%d", &x);
    scanf("%d%d", &h, &m);
    printf("%d\n", luck(h, m, x));
    return 0;
#else
    return test();
#endif
}

int unit(int h, int m, int x, int e) {
    int r;
    if (e != (r = luck(h, m, x))) {
        printf("fail at luch(%d, %d, %d) = %d != %d\n", h, m, x, r, e);
    }
}
int test() {
    unit(11, 23, 3, 2);
    unit(1, 7, 5, 0);
    unit(0, 0, 3, 1);
    unit(0, 0, 1, 3);
    unit(0, 0, 2, 181);
    return 0;
}

#include <stdio.h>

int main()
{
    int x, h, m, count;
    count = 0;
    scanf("%d %d %d", &x, &h, &m);
    for(;;)
    {
        if(m%10 == 7 || h%10 == 7)
        {
            printf("%d", count);
            break;
        }
        else
        {
            m = m - x;
            if(m < 0)
            {
                h--;
                m = m + 60;
            }
            if(h < 0)
            {
                h = h + 24;
            }
        }
        count++;
    }
    return 0;
}

#include <stdio.h>

int main (void)
{
	int x, h, m, count=0;
	scanf ("%d %d %d", &x, &h, &m);

	while (h%10!=7 && m%10!=7)
	{
		m=m-x;

		while (m<0)
		{
			m=60+m;
			h--;
		}
		while (h<0)
			h=24+h;
		count++;
	}

	printf("%d\n", count);

	return 0;
}

#include<stdlib.h>
#include<stdio.h>
int main()
{int hh,mm,x,y=0;
scanf("%d",&x);
scanf("%d %d",&hh,&mm);
while(hh%10!=7 && mm%10!=7)
{   mm=mm-x;
   y++;
  if(mm<0)

    {mm=mm+60;
    hh--;}
  if(hh<0)
    {hh=hh+24;}

}
printf("%d",y);
    return(0);
}

#include<stdio.h>
#include<stdlib.h>

long long find(long long h,long long m){
long long k;
while(h!=0){
k=h%10;
if(k==7){
return 0;};
h=h/10;}

while(m!=0){
k=m%10;
if(k==7){
return 0;}
m=m/10;}

return -1;}

void main(){
long long x,h,m,k1,k2,k,count=0;
scanf("%lld",&x);
scanf("%lld %lld",&h,&m);

k1=h;k2=m;

while(k2!=0){
k=k2%10;
if(k==7){
printf("0\n");exit(0);};
k2=k2/10;}

while(k1!=0){
k=k1%10;
if(k==7){
printf("0\n");exit(0);}
k1=k1/10;}

while(1){

count++;

if(m<x){
m=60-(x-m);
if(h==0)
	h=23;
else
h=h-1;

if(find(h,m)==0){
printf("%lld\n",count);exit(0);}}

else if(m>=x){
m=m-x;

if(find(h,m)==0){
printf("%lld\n",count);exit(0);}}

}

exit(0);}

#include<stdio.h>

int x, nSnoozes;
int hh, mm;
int h, m;

int checkLucky(int n)
{
	while (n > 0)
	{
		if (n % 10 == 7)
		{
			return 1;
		}
		n = n / 10;
	}
	return 0;
}

void cntSnoozes(int a, int b)
{

	if (checkLucky(a) || checkLucky(b))
	{
     //  printf("%d :%d  nSnoozes : %d \n",a,b,nSnoozes);
		return;
	}
	else
	{
		int tx = x, th = a, tm = b;
		while (tm >= 0)
		{
		//	printf(" in while%d :%d  snooze is : %d \n",th,tm,nSnoozes);
			tm -= x; nSnoozes++;
			//printf(" updated %d :%d nSnoozes :%d \n",th,tm,nSnoozes);
			if (tm < 0){
			//	printf("negative %d :%d  nSnoozes : %d \n",th,tm,nSnoozes);
				break;}

			else if (checkLucky(tm))
				return;
		}
		if (th == 0)
		{
			th = 23;
		}
		else   th = th - 1;

		tm = 60 + tm; //nSnoozes++;
	//	printf(" outside updated %d :%d nSnoozes : %d \n",th,tm,nSnoozes);
		cntSnoozes(th, tm);
	}
	return;
}

int main()
{
		x = hh = mm = nSnoozes = 0;
		scanf("%d", &x);
		scanf("%d %d", &h, &m);

		int th = checkLucky(h);
		int tm = checkLucky(m);
		if (th == 1 || tm == 1)
			nSnoozes = 0;
		else cntSnoozes(h, m);
		printf("%d\n", nSnoozes);
		return 0;
	}

#include <stdio.h>

int main()
{
	int x,hh,mm;
	int h,m;
	int a,i;

	scanf("%d", &x);
	scanf("%d %d", &hh, &mm);

	for(i=0; ; i++)
	{
	    h=hh%10;
		m=mm%10;

		mm=mm-x;
		if(mm<0)
		{
			mm=mm+60;
			hh=hh-1;
		}
		if(hh<0)
		{
			hh=hh+24;
		}

		if(h==7 || m==7 || (hh==7 && mm==0) )
		{
			break;
		}
	}
	printf("%d\n", i);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int lucky_checker(int h,int m);
void time_minus(int *h, int *m);

int main()
{
	int x,hour,min,counter=0;
	float button_times;
	int loop_x;

	scanf("%d %d %d",&x,&hour,&min);
	loop_x = x;

	while(! lucky_checker(hour,min)) {
		counter++;
		loop_x = x;
		while(loop_x--) {
			//printf("%d\n",loop_x);
			//getchar();
			time_minus(&hour,&min);
		}
		//printf("%d:%d\n",hour,min);
	}
	//printf("%d %d\n",hour,min);
	//button_times = (float)counter/x;
	//if (button_times>0 && button_times<1)
		//button_times=1;

	//printf("%d\n",(int)button_times);
	printf("%d\n",counter);

//	check 7
//	no 7
//	minus 1 min
//	check 7 or change hour

	return 0;
}

int lucky_checker(int h,int m)
{
	int lucky=0,checker_7;
	while(h || m) {
		checker_7 = h%10;
		if (checker_7==7) {
			//printf("Hour yes\n");
			lucky=1;
			break;
		}
		h/=10;

		checker_7 = m%10;
		if (checker_7==7) {
			//printf("Min yes\n");
			lucky=1;
			break;
		}
		m/=10;
	}
	return lucky;
}

void time_minus(int *h, int *m)
{
	if (*m == 0) {
		*h-=1;
		*m = 59;
		if (*h < 0) {
			*h = 23;
		}
	}
	else {
		*m -=1;
	}
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <math.h>

int main()
{
    int x,hh,mm,ans=0;
    scanf("%d %d %d",&x,&hh,&mm);
    while(mm%10!=7){
        if(hh%10==7){
            break;
        }
        if(mm>=x){
            mm-=x;
        }
        else{
            mm=60-(x-mm);
            if(hh==0){
                hh=23;
            }
            else{
                hh--;
            }
        }
        ans++;

    }
    printf("%d",ans);

    return 0;
}

#include<stdio.h>
int fun(int h, int m){
	if(m%10==7 || h%10==7)return 0;
	return 1;
}
int main(){
	int x,h,m,h1,m1,ans=0;
	scanf("%d%d%d",&x,&h,&m);
	h1=h;
	m1=m;
	while(fun(h,m)){
		ans++;
		m-=x;
		if(m<0){
			h--;
			if(h<0)h=23;
			m+=60;
		}
	}
	printf("%d\n",ans);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int x, hh, mm, res = 0;
	scanf("%d", &x);
	scanf("%d%d", &hh, &mm);

	while ((hh - 7) % 10 != 0 && (mm - 7) % 10 != 0) {
		mm -= x;
		if (mm < 0) {
			mm += 60;
			if (hh == 0) {
				hh = 24;
			}
			--hh;
		}
		++res;
	}

	printf("%d", res);
	return 0;
}

#include <stdlib.h>
#include <stdio.h>

typedef struct{
	int hh,mm;
}Time;

void *goBack(Time *time, int min){

	time->mm -= min;
	if(time->mm < 0){
		time->mm  += 60;
		time->hh--;
		if(time->hh < 0)
			time->hh += 24;
	}

}

int solve(Time *time, int n){
	int total = 0;
	int luck = 0;

	if(time->hh % 10 == 7 || time->mm % 10 == 7)
		return total;

	while(luck == 0){
		total++;
		goBack(time,n);
		if(time->hh % 10 == 7 || time->mm % 10 == 7)
			luck = 1;

	}

	return total;
}

int main(){

	int n;
	Time *time = (Time*)malloc(sizeof(Time));

	scanf("%d %d %d",&n, &time->hh, &time->mm);

	printf("%d\n",solve(time,n));

	return 0;
}

#include<stdio.h>
// 1 means lucky
int check(int a,int b)
{if(a%10==7 || b%10==7)
return 1;
else
return 0;
}
int main()
    {int x,a,b,count=0;
    scanf("%d %d %d",&x,&a,&b);
    while(check(a,b)==0)
    {  count++;
    if((b-x)>=0)
    b=b-x;
    else
    {b=b-x+60;
    if(a-1<0)
    a=a-1+24;
        else
        a=a-1;
    }

    }
    printf("%d",count);
    }

#include<stdio.h>
int is_lucky(int hh, int mm);
int main()
{
    int hh,mm,x,y,i,j;
    while(scanf("%d",&x)==1){
        scanf("%d %d",&hh,&mm);
        y=0;

        while(is_lucky(hh,mm)!=1){
            mm=mm-x;
            y++;
            if(mm<0){
                mm=60+mm;
                hh--;
            }
            if(hh<0)
                hh=24+hh;

        }
        printf("%d\n",y);
    }
    return 0;
}
int is_lucky(int hh, int mm)
{
    while(mm!=0){
        if(mm%10==7)
            return 1;
        mm/=10;
    }
    while(hh!=0){
        if(hh%10==7)
            return 1;
        hh/=10;
    }
    return 0;
}

#include <stdio.h>

int main()
{
    int x,shi,fen,c=0;
    scanf("%d",&x);
    scanf("%d%d",&shi,&fen);
    while(1)
    {
        if(shi%10==7 || fen%10==7)
            break;
        fen-=x;
        if(fen<0)
        {
            fen=60+fen;
            shi-=1;
            if(shi<0)
                shi=24+shi;
        }
        c++;
    }
    printf("%d\n",c);
    return 0;
}

#include<stdio.h>

int main()
{
    int x, hr, mm, ans = 0, tm;

    scanf("%d", &x);
    scanf("%d %d", &hr, &mm);
    tm = (hr * 60) + mm;

    while(1)
    {
        hr = tm / 60;
        mm = tm % 60;
        if(hr % 10 == 7 || mm % 10 == 7)
            break;
        else
        {
            ans++;
            if(tm < x)
                tm = tm + 1440;
            tm = tm - x;
        }
    }

    printf("%d\n", ans);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){

   int i,x,hh,mm,snooze=0;
   scanf("%d",&x);
   scanf("%d %d",&hh,&mm);
   while(1){

   condition:
    if((hh==7)||(hh==17)||(mm%10==7)){
        break;
    }
    if(x>mm){
            mm = 60-x+mm;
            snooze++;
            hh--;
            if(hh<0){
            hh = 23;
            }
            goto condition;
        }
        mm-=x;
        snooze++;

        }

    printf("%d ",snooze);

}

#include <stdio.h>

int main(){
    int x,hh,mm,i=0;
    scanf("%d",&x);
    scanf("%d %d",&hh,&mm);
    while(((hh%10)!=7)&&((mm%10)!=7)){
       i++;
       if(mm<x){
          mm=(mm+60-x);
          if(hh==0)
            hh=23;
          else
            hh=hh-1;
       }
       else{
        mm=mm-x;
       }
    }
     printf("%d",i);
  return 0;
}

#include <stdio.h>
#include <string.h>
int counter=0;

void check(int hh, int mm, int snooze){

	while(mm % 10 != 7 && hh % 10 != 7){
		mm -= snooze;
		if(mm < 0){
			mm = mm + 60;
			hh--;
			if(hh < 0)
				hh = hh + 24;
		}
		counter++;
	}
	//printf("%d",counter);
}

int main(void){
	int snooze;
	int hh, mm;
	//int finalcounter=0;

	scanf("%d",&snooze);
	scanf("%d %d", &hh, &mm);

	check(hh,mm,snooze);

	printf("%d\n",counter);
	return 0;

}

#include<stdio.h>
main()
{

    int x,hour,d,minute,click=0,snooze,c;
    scanf("%d",&x);
    scanf("%d %d",&hour,&minute);
    c = hour;
    d = minute;
    while(1)
        {
            if(hour==0)
            {
                hour=24;

            }
    click++;

    if(x <= minute)
        snooze = minute-x;
    else
      {
          snooze = 60 + (minute-x);
             hour = hour-1;

        if(hour%10==7)
            {

            break;
            }
      }

        if(snooze%10==7)
        {

            break;
        }
        else
            minute=snooze;

}

if(c%10==7||d%10==7)
    click=0;
printf("%d",click);
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
    int x;int y,v,s;v=0;
    int sa,sb,r;
    scanf("%d",&x);
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<10000;i++)
    {
        sb=abs(b);
        sa=abs(a);
        while(sb>0)
        {
          r=sb%10;
          sb=sb/10;
          if(r==7)
          {
              s=i;v=1;
              break;
          }
        }
        if(v==1)
        {
            break;
        }
        while(sa>0)
        {
          r=sa%10;
          sa=sa/10;
          if(r==7)
          {
              s=i;v=1;
              break;
          }
        }
        if(v==1)
        {
            break;
        }
        b=b-x;
        if(b<0)
        {
            b=60+b;
            a=a-1;
        }
    }
             printf("%d",s);
}

#include<stdio.h>

int check(int h,int m){
	if(h%10==7||m%10==7)
		return 0;
	h/=10;
	m/=10;
	if(h%10==7||m%10==7)
		return 0;
	return 1;
}
void adjust(int *h,int *m,int x){
	if(*m<x){
		if(*h==0)
			*h=23;
		else
			*h=*h-1;
		*m=*m+60;
	}
	*m=*m-x;

}
int main(){
	int x,h,m;
	scanf("%d%d%d",&x,&h,&m);
	int count=0;
	while(check(h,m)){
		count++;
		adjust(&h,&m,x);
	}
	printf("%d\n",count);
	return 0;
}

#include <stdio.h>
int main(){
	int x,h,m;
	int lh,lm;
	int cnt = 0;
	scanf("%d",&x);
	scanf("%d %d",&h,&m);
	for(;;){
		if(m%10==7){
			printf("%d",cnt);
			break;
		}
		if(h%10==7){
			printf("%d",cnt);
			break;
		}
		m = m - x;
		cnt++;
		if(m<0){
			m = 60 + m;
			h = h - 1;
			if(h<0){
				h = 23;
			}
		}
		if(m%10==7){
			printf("%d",cnt);
			break;
		}
		if(h%10==7){
			printf("%d",cnt);
			break;
		}
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int x, hh, mm;
    scanf("%d%d%d",&x,&hh,&mm);

    if(hh== 17 || hh == 7)
    {
        printf("0\n");
        return 0;
    }
    int remainder = mm % 10;
    if(remainder - 7 == 0)
    {
        printf("0\n");
        return 0;
    }
    int temp, y = 0, count = 0;

    while(count<=0)
    {
        if(mm>=x)
        {
            mm = mm - x;
            y++;

        }
        else
        {
            if(hh==0)
            {
                hh = 24;
            }
            temp = x - mm;
            mm = 60 - temp;
            hh--;
            y++;

        }
        remainder = mm % 10;
        if(remainder - 7 == 0)
        {
            count++;
        }
        if(hh == 7 || hh == 17)
        {
            count++;
        }
    }
    printf("%d",y);
    return 0;
}

#include <stdio.h>

int x, hh, mm,ans;
int main()
{
    scanf("%d%d%d", &x, &hh, &mm);
    while (1)
    {
        if (hh % 10 == 7 || mm % 10 == 7)break;
        ans++;
        mm -= x;
        if (mm < 0)
        {
            hh--;
            mm += 60;
        }
        if (hh < 0)hh += 24;
    }
    printf("%d", ans);
    return 0;
}

#include <stdio.h>
int main()
{
    int x,hh,mm,c=0;
    scanf("%d%d%d",&x,&hh,&mm);
    while(1)
    {
        if(hh%10==7||mm%10==7)
        {printf("%d",c);
         break;
        }
        else
       { mm-=x;
        c++;
        if(mm<0)
        { mm+=60;
          hh--;
          if(hh<0)
          hh+=24;
        }
       }
    }

    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2;

scanf("%lld%lld%lld",&n,&a,&b);
count=0;

while(a%10!=7 && b%10!=7){
    b-=n;
    count++;
    if(b<0){
        b=60+b;
        a--;
    }
    if(a<0){
        a=23;
    }
}
printf("%lld",count);
return 0;
}

#include<stdio.h>
#include<stdlib.h>

int cmpfunc(const void *a, const void *b){
    return (*(int *)a) - (*(int *)b);
}

int main(){
    int x,h,m,count=0;
    scanf("%d",&x);
    scanf("%d %d",&h,&m);
    while((h%10)!=7 && (m%10)!=7){
        if(x > m){
            m = 60 - (x-m);
            if(h==0)    h = 23;
            else    h--;
        }
        else{
            m -= x;
        }
        count++;
    }
    printf("%d",count);
    return 0;
}

#include <stdio.h>
int check(int h,int m)
{
	if((h%10)==7 || (m%10)==7)
	{
		return 1;
	}
	else return 0;
}
int findy(int x,int h, int m)
{
	int i=0,k=0;
	if(m<x)
	{
		h--;
		m=(60+m)-x;
		i++;
		if(check(h,m))
			return i;
	}
	if(m<x && h<=0)
	{
		h=23;
		m=(60+m)-x;
		i++;
		if(check(h,m))
			return i;
	}
	else
	{
		m=m-x;
		i++;
		if(check(h,m))
			return i;
	}
	return i+findy( x,h,m);
}
int main()
{
	int x,h,m;
	scanf("%d%d%d",&x,&h,&m);
	if(check(h,m))
	{
		printf("0");
		return 0;
	}
	else
	{
		int y;
		y=findy(x,h,m);
		printf("%d",y);
	}
	return 0;
}

#include <stdio.h>

int main()
{
	int x,hh,mm;
	int h,m;
	int a,i;

	scanf("%d", &x);
	scanf("%d %d", &hh, &mm);

	for(i=0; ; i++)
	{
	    h=hh%10;
		m=mm%10;

		mm=mm-x;
		if(mm<=0)
		{
			mm=mm+60;
			hh=hh-1;
		}
		if(hh<=0)
		{
			hh=hh+24;
		}

		if(h==7 || m==7)
		{
			break;
		}
	}
	printf("%d\n", i);
	return 0;
}

#include<stdio.h>

int main()
{
    int x, hr, mm, ans = 0, tm;

    scanf("%d", &x);
    scanf("%d %d", &hr, &mm);
    tm = (hr * 60) + mm;

    while(1)
    {
        hr = tm / 60;
        mm = tm % 60;
        if(hr % 10 == 7 || mm % 10 == 7)
            break;
        else
        {
            ans++;
            tm = tm - x;
        }
    }

    printf("%d\n", ans);

    return 0;
}

#include <stdio.h>
#define nax 1000
int main()
{

	int x, hours,minutes;
	scanf("%i",&x);
	scanf("%d%d",&hours,&minutes);
	int newHour = minutes;
	int minus;
	int counter = 0 ;
	while (1){

		if (newHour % 10 == 7 || hours % 7 == 0 ){
			break;
		}

		if (newHour < x){
			minus = x - newHour;
			newHour = 60 - minus;
			hours -=1;
		}

		else
		{
			newHour -=  x;
		}
		counter += 1;

	}
	printf("%i",counter);

}

#include<stdio.h>
main()
{
    int x,minute,time_delay=0,k,hour;
    scanf("%d",&x);
    scanf("%d %d",&hour,&minute);
    hour = hour%10;
    while(1)
    {

        k = minute%10;

        if(k==7||hour==7)
            break;
            if(minute==0)
            {
                if(hour-1==7)
                {

                    minute--;
                    time_delay++;
                    break;
                }
                else
                    minute = 60;
            }
             minute--;
                  time_delay++;
    }
    if(time_delay/x==0)
        time_delay = time_delay%x;
    else
        time_delay = time_delay/x;

    printf("%d",time_delay);
}

#include<stdio.h>
main()
{

    int x,hour,d,minute,click=0,snooze,c;
    scanf("%d",&x);
    scanf("%d %d",&hour,&minute);
    c = hour;
    d = minute;
    while(1)
        {
            if(hour==0)
            {
                hour=24;

            }
    click++;

    if(x <= minute)
        snooze = minute-x;
    else
      {
          snooze = 60 + (minute-x);
             hour = hour-1;

        if(hour%10==7)
            {

            break;
            }
      }

        if(snooze%10==7)
        {

            break;
        }
        else
            minute=snooze;

}
if(c%10==7||d==0)
    click=0;
printf("%d",click);
}

#include<stdio.h>
int main()
{
    int x;int y,s;
    scanf("%d",&x);
    int a,b;
    scanf("%d%d",&a,&b);
    y=b%10;
    if(y<7)
    {
    y=y+3;
    }
    else
    {
        y=y-7;
    }
    if(y%x==0)
    {
        s=y/x;
    }
    else
    {
        s=y/x;
        s=s+1;
    }
    printf("%d",s);
}

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>

int x, hh, mm,ans=0x7fffffff,sh,sm,tmp1,tmp2;
int myabs(int x) { return x > 0 ? x : -x; }
int main()
{
    scanf("%d%d%d", &x, &hh, &mm);
    if (hh % 10 == 7 || mm % 10 == 7)
    {
        putchar('0');
        return 0;
    }
    tmp1 = hh * 60 + mm;
    for (sh = 0; sh < 24; ++sh)
    {
        for (sm = 0; sm < 60; ++sm)
        {
            if (sh == hh && sm == mm)continue;
            if (sh % 10 != 7 && sm % 10 != 7)continue;
            tmp2 = (sh * 60 + sm);
            tmp2 += tmp2 > tmp1 ? 24 * 60 : 0;
            tmp2 -= tmp1;
            if (tmp2 < 0)tmp2 = -tmp2;
            if (tmp2 % x == 0)
            {
                //printf("%d:%d - %d:%d is %d\n", hh, mm,sh, sm,tmp2);
                tmp2 /= x;
                if (tmp2 <= ans)ans = tmp2;
            }
        }
    }
    printf("%d", ans);
    return 0;
}

#include <stdio.h>

int main()
{
    int x, h, m, count;
    count = 0;
    scanf("%d %d %d", &x, &h, &m);
    for(;;)
    {
        if(m%10 == 7 || h%10 == 7)
        {
            printf("%d", count);
            break;
        }
        else
        {
            m = m - x;
            if(m <= 0)
            {
                h--;
                m = m + 60;
            }
            if(h < 0)
            {
                h = h + 24;
            }
        }
        count++;
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <math.h>

int main()
{
    int x,hh,mm,ans=0;
    scanf("%d %d %d",&x,&hh,&mm);
    while(mm%10!=7){
        if(mm>=x){
            mm-=x;
        }
        else{
            mm=60-(x-mm);
            if(hh==0){
                hh=23;
            }
            else{
                hh--;
            }
        }
        ans++;
        if(hh%10==7){
            break;
        }
    }
    printf("%d",ans);

    return 0;
}

#include<stdio.h>
main()
{
    int x,minute,time_delay=0,k,hour,c;
    scanf("%d",&x);
    scanf("%d %d",&hour,&minute);
    c=minute;
    hour = hour%10;
    while(1)
    {

        k = minute%10;

        if(k==7||hour==7)
            break;
            if(minute==0)
            {
                if(hour-1==7)
                {

                    minute--;
                    time_delay++;
                    break;
                }
                else
                    minute = 60;
            }
             minute--;
                  time_delay++;
    }
    if(time_delay/x==0)
        time_delay = 1;
    else
        time_delay = time_delay/x;
        if(hour==7||c%10==7)
            time_delay=0;

    printf("%d",time_delay);
}

#include<stdio.h>

int check(int h,int m)
{
	int hh[2]={0},mm[2]={0},i=0,j=0,count=0;
	while(h>0)
	{
		if(h%10==7)
		{
			count++;
		}
		h=h/10;
	}
	while(m>0)
	{
		if(m%10==7)
		{
			count++;
		}
		m=m/10;
	}
	return count;
}
int main()
{
	int x;
	scanf("%d",&x);
	int h,m,count1=0,count=0,i;
	scanf("%d %d",&h,&m);
	while(1)
	{
		count=check(h,m);
	//	printf("%d %d\n",h,m);
	//	printf("%d\n",count );
		if(count>0)
		{
	//		printf("%d\n",count1 );
			break;
		}
		else
		{
			h--;
			m=m-x;
			if(h<0)
			{
				h=24+h;
			}
			if(m<0)
			{
				m=60+m;
			}
			h=h%24;
			m=m%60;
			count1++;
		}
	}
	printf("%d\n", count1);
	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>

int x, hh, mm,ans;
int main()
{
    scanf("%d%d%d", &x, &hh, &mm);
    while (mm-=x)
    {
        if (hh % 10 == 7 || mm % 10 == 7)break;
        if (mm < 0)
        {
            hh--;
            mm += 60;
        }
        if (hh < 0)hh += 24;
        ans++;
    }
    printf("%d", ans);
    return 0;
}

#include <stdio.h>

int main()
{
    int y=0;
    int x;
    int hh,mm;
    scanf("%d",&x);
    scanf("%d %d",&hh,&mm);

    while(1)
    {
        if((hh%10==7)||(mm%10==7))
        {
            break;
        }
        if(mm-x<0)  //分钟数小于7
        {
            mm=60+mm-x;//
            if(hh-1<0)
            {
                hh=24;
            }
            else
            {
                hh--;
            }
        }
        else
        {
            mm=mm-x;
        }
        //printf("\nhh:mm=%d:%d\n",hh,mm);
        y++;
    }
    printf("%d\n",y);

    return 0;
}

#include<stdio.h>
main()
{

    int x,hour,d,minute,click=0,snooze,c;
    scanf("%d",&x);
    scanf("%d %d",&hour,&minute);
    c = hour;
    d = minute;
    while(1)
        {
            if(hour==0)
            {
                hour=24;

            }
    click++;
    if(x < minute)
        snooze = minute-x;
    else
      {
          snooze = 60 + (minute-x);
             hour = hour-1;

      }

        if(hour%10==7)
            {

            break;
            }
        if(snooze%10==7)
        {
            click++;
            break;
        }
        else
            minute=snooze;

}
if(c%10==7||d==0)
    click=0;
printf("%d",click);
}

#include <stdio.h>

int islucky(int HH,int MM){
	if(HH%10==7 || HH/10==7 || MM%10==7 || MM/10==7) return 1;
	else return 0;
}

int main(){
	int a,b,HH,MM,t=0,n,x;
	scanf("%d",&x);
	scanf("%d %d",&HH,&MM);
	n=(HH*60)+MM;
	a=HH;
	b=MM;
	while(islucky(a,b)==0){
		t=t+1;
		n=n-x;
		a=n/60;
		b=n%60;
	}
	printf("%d",t);
}

#include<stdio.h>
int main()
{
    int x,h,m,a,y;
    scanf("%d%d%d",&x,&h,&m);
    if(m%10==7)
    {
        printf("0");
        return 0;
    }
    a=m;
    while(a%10!=7)
    {
        a--;
    }
    y=ceil((m-a)/x);
    printf("%d",y);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main()
{
	int n = 0;
	int hh = 0, mm = 0;
	scanf("%d %d %d",&n,&hh,&mm);
	int count = 0;
	while(  mm % 10 != 7 && hh % 10 != 7)
	{
		count++;
		if ( mm > n )
		{
			mm -= n;
		}
		else if ( mm == n)
		{
			mm = 59;
			hh -= 1;
		}
		else
		{
			mm = mm + 60 - n;
			hh -= 1;
		}
	}
	printf("%d\n",count);
	return 0;
}

#include <stdio.h>

int main()
{
    int x, hh, mm, ans = 0;
    scanf("%d %d %d", &x, &hh, &mm);
    while(1) {
        if(mm % 10 == 7) {
            break;
        }
        if(--mm == 0) {
            mm = 59;
            if(--hh == 0) {
                hh = 23;
            }
        }
        ++ans;
    }
    printf("%d\n", ans / x);
    return 0;
}

#include <stdio.h>
int main()
{
    int x,hh,mm,c=0;
    scanf("%d%d%d",&x,&hh,&mm);
    while(1)
    {
        if(hh%10==7||mm%10==7)
        {printf("%d",c);
         break;
        }
        else
       { mm-=x;
        c++;
        if(mm<0)
        { mm+=59;
          hh--;
          if(hh<0)
          hh+=23;
        }
       }
    }

    return 0;
}

#include<stdio.h>

int seven(int x,int y)
{
	int p;
	if(x==7||y==7||(x/10)==7||(y/10)==7)
		return 1;
	x=x%10;
	y=y%10;
	if(x==7||y==7)
		return 1;
	else
		return 0;
}

int main()
{
	int x,hh,mm,i=0,p=0;
	scanf("%d%d%d",&x,&hh,&mm);
	for(i=0;i<10000;i++)
	{
		if(seven(hh,mm)==1)
		{
			break;
		}
		if(x<=mm)
		{
			mm=mm-x;
		}
		if(x>mm)
		{
			mm=60+mm-x;
			if(hh==0)
				hh=23;
			else
				hh=hh-1;
		}
		p++;
	}
	printf("%d\n",p);
	return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2;

scanf("%lld%lld%lld",&n,&a,&b);
count=0;

while(a%10!=7 && b%10!=7){
    b-=3;
    count++;
    if(b<0){
        b=59+b;
        a--;
    }
    if(a<0){
        a=24;
    }
}
printf("%lld",count);
return 0;
}

#include<stdio.h>
struct time{
	int hour;
	int minute;
};
int whether(int x);
int main()
{
	struct time times;
	int x,item=0;
	scanf("%d%d%d",&x,&times.hour,&times.minute);

	while(1)
	{
		if(whether(times.hour)||whether(times.minute))
		{
			printf("%d\n",item);
			return 0;
		}
		else
		{
			if((times.minute-x)>=0)
			{
				times.minute-=x;
			}
			else {
				times.minute=times.minute+60-x;
				if(times.hour>=1)
					times.hour-=1;
				else
					times.hour=23;
			}
		}
		item++;
		//printf("%d:%d\n",times.hour,times.minute);
	}

	return 0;
}
int whether(int x)
{
	while(x)
	{
		if(x%10==7)
		{
			return 1;
		}
		else
		{
			x/=7;
		}
	}
	return 0;
}

#include<stdio.h>
struct time{
	int hour;
	int minute;
};
int whether(int x);
int main()
{
	struct time times;
	int x,item=0;
	scanf("%d%d%d",&x,&times.hour,&times.minute);

	while(1)
	{
		if(whether(times.hour)||whether(times.minute))
		{
			printf("%d\n",item);
			break;
		}
		else
		{
			if((times.minute-x)>=0)
			{
				times.minute-=x;
			}
			else {
				times.minute=times.minute+60-x;
				if(times.hour>=1)
					times.hour-=1;
				else
					times.hour=23;
			}
		}
		item++;
		printf("%d:%d\n",times.hour,times.minute);

	}

	return 0;
}
int whether(int x)
{
	while(x)
	{
		if(x%10==7)
		{
			return 1;
		}
		else
		{
			x/=10;
		}
	}
	return 0;
}

#include<stdio.h>
int yeah(int n)
{
    while(n){
        if(n%10==7) return 1;
        n/=10;
    }
    return 0;
}
int main()
{
    int h,m,time,count1=0,ans1,ans2,count2=0,count=0,x,i;
    scanf("%d",&x);
    scanf("%d %d",&h,&m);
    if((yeah(h)==1)||(yeah(m)==1)) printf("0\n");
    else {
            for(;;){
            if((m-x)==0) m=60;
            else if((m-x)<0) {
                m=60-(x-m);
                h-=1;
            }
            else m-=x;
            ++count;
            if(h<0) h=24+h;
            if((yeah(h)==1)||(yeah(m)==1)) break;

    }
    printf("%d\n",count);
    }
    return 0;
}

#include <stdio.h>
int check(int h,int m)
{
	if((h%10)==7 || (m%10)==7)
	{
		return 1;
	}
	else return 0;
}
int findy(int x,int h, int m)
{
	int i=0,k=0;
	if(m<x || h<=0)
	{
		if(m<x)
		{
			h--;
			m=(60+m)-x;
			i++;
			if(check(h,m))
				return i;
		}
		if(h<=0)
		{
			h=23;
			m=(60+m)-x;
			i++;
			if(check(h,m))
				return i;
		}
	}
	else
	{
		m=m-x;
		i++;
		if(check(h,m))
			return i;
	}
	return i+findy( x,h,m);
}
int main()
{
	int x,h,m;
	scanf("%d%d%d",&x,&h,&m);
	if(check(h,m))
	{
		printf("0");
		return 0;
	}
	else
	{
		int y;
		y=findy(x,h,m);
		printf("%d",y);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int lucky_checker(int h,int m);
void time_minus(int *h, int *m);

int main()
{
	int x,hour,min,counter=0;
	float button_times;

	scanf("%d %d %d",&x,&hour,&min);

	while(! lucky_checker(hour,min)) {
		counter++;
		time_minus(&hour,&min);
		//printf("%d:%d\n",hour,min);
	}
	//printf("%d %d\n",hour,min);
	button_times = (float)counter/x;
	if (button_times>0 && button_times<1)
		button_times=1;

	printf("%d\n",(int)button_times);

//	check 7
//	no 7
//	minus 1 min
//	check 7 or change hour

	return 0;
}

int lucky_checker(int h,int m)
{
	int lucky=0,checker_7;
	while(h || m) {
		checker_7 = h%10;
		if (checker_7==7) {
			//printf("Hour yes\n");
			lucky=1;
			break;
		}
		h/=10;

		checker_7 = m%10;
		if (checker_7==7) {
			//printf("Min yes\n");
			lucky=1;
			break;
		}
		m/=10;
	}
	return lucky;
}

void time_minus(int *h, int *m)
{
	if (*m == 0) {
		*h-=1;
		*m = 59;
		if (*h < 0) {
			*h = 23;
		}
	}
	else {
		*m -=1;
	}
}

#include <stdio.h>

int main()
{
	int x;
	int h, m;
	scanf("%d%d%d",&x,&h,&m);
	int ans=0;
	while (m%10!=7 && h!=7){
		ans++;
		m -= x;
		if (m<=0){
			h--;
			m += 60;
		}
		if (h==0) h=12;
	}
	printf("%d",ans);
	return 0;
}

#include<stdio.h>

int min, hh, mm;
int cnt = 0;

int is_lucky(int hh, int mm) {
  return hh/10 == 7 || hh%10 == 7 || mm/10 == 7 || mm%10 == 7;
}

int get_lucky(int hh, int mm) {
  if(is_lucky(hh, mm))
    return hh*100 + mm;

  if(mm == 0) {
    if(hh == 0)
      return get_lucky(23, 59);
    return get_lucky(hh-1, 59);
  }
  return get_lucky(hh, mm-1);
}

int get_times(int lhh, int lmm) {
  if((lhh == hh && lmm == mm) || (lhh >= hh && lmm >= mm))
    return cnt;

  cnt++;
  lmm += min;
  if(lmm >= 60) {
    lhh += 1;
    lmm -= 60;
  }
  if(lhh >= 24)
    lhh = 0;
  return get_times(lhh, lmm);
}

int main() {
  scanf("%d %d %d", &min, &hh, &mm);
  int luck_hh = get_lucky(hh, mm) / 100, luck_mm = get_lucky(hh, mm) % 100;

 printf("%d\n",get_times(luck_hh, luck_mm));
}

#include <stdio.h>
#include <string.h>
int main()
{
   int x,hh,mm,i,flag=0,l,point,h;
   scanf("%d",&x);
   scanf("%d%d",&hh,&mm);
   h=hh;
   for (i=mm;i>=0;i--)
   {
   	 if (i==7||i==17||i==27||i==37||i==47||i==57)
	 {
	 	flag =1;
	 	point=i;
	 	break;
	 }
   }
   if (flag==0)
   {
   	  h=hh-1;
   	  point=57;
   }
   if (h==hh)
   {
   	  l=(mm-point)/x;
   }
   else if(h!=hh)
   {
   	l=(3+mm)/x;
   }
   printf("%d\n",l);
}

#include <stdio.h>
#include <string.h>
int counter;

void check(int hh, int mm, int snooze){

	if (mm % 10 == 7 || hh % 10 == 7){
		//memset(counter,0,sizeof(counter));
		printf("%d",counter);
	}
	else{
		do{
			mm -= snooze;
			if(mm < 0){
				mm = mm + 60;
				hh--;
			}
			counter++;
		}while(mm % 10 != 7);
	printf("%d",counter);
	}

}

int main(void){
	int snooze;
	int hh, mm;
	//int finalcounter=0;

	scanf("%d",&snooze);
	scanf("%d %d", &hh, &mm);

	check(hh,mm,snooze);

	printf("%d\n",counter);
	return 0;

}

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>

int x, hh, mm,ans=0x7fffffff,sh,sm,tmp1,tmp2;
int myabs(int x) { return x > 0 ? x : -x; }
int main()
{
    scanf("%d%d%d", &x, &hh, &mm);
    if (hh % 10 == 7 || mm % 10 == 7)
    {
        putchar('0');
        return 0;
    }
    tmp1 = hh * 60 + mm;
    for (sh = 0; sh < 24; ++sh)
    {
        for (sm = 0; sm < 60; ++sm)
        {
            if (sh == hh && sm == mm)continue;
            if (sh % 10 != 7 && sm % 10 != 7)continue;
            tmp2 = myabs(tmp1 - (sh*60+sm));
            if (tmp2 % x == 0)
            {
                //printf("%d:%d - %d:%d is %d\n", hh, mm,sh, sm,tmp2);
                tmp2 /= x;
                if (tmp2 <= ans)ans = tmp2;
            }
        }
    }
    printf("%d", ans);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,h,m,a,y;
    scanf("%d%d%d",&x,&h,&m);
    if(m%10==7)
    {
        printf("0");
        return 0;
    }
    a=m;
    while(a%10!=7)
    {
        a--;
    }
    y=ceil((m-a)/x);
    printf("%d",y);
    return 0;
}

#include <stdio.h>
#define nax 1000
int main()
{

	int x, hours,minutes;
	scanf("%i",&x);
	scanf("%d%d",&hours,&minutes);
	int newHour = minutes;
	int minus;
	int counter = 0 ;
	while (1){

		if (newHour % 10 == 7)
			break;
		if (newHour < x){
			minus = x - newHour;
			newHour = 59 - minus;
		}
		else
		{
			newHour -=  x;
		}
		counter += 1;

	}
	printf("%i",counter);

}

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int x, hh, mm, dist = 0, res = 0;
	scanf("%d", &x);
	scanf("%d%d", &hh, &mm);

	while ((hh - 7) % 10 != 0 && (mm - 7) % 10 != 0) {
		if (mm == 0) {
			mm = 60;
			if (hh == 0) {
				hh = 24;
			}
			--hh;
		}
		--mm;
		if (dist++ % x == 0)
			++res;
	}

	printf("%d", res);
	return 0;
}


#include<stdio.h>
int main()
{
    int n,feet,tmp,inch;
    scanf("%d",&n);
    inch=n/3;
    if(n%3==2)
    {
        inch++;
    }
    feet=inch/12;
    inch=inch%12;
    printf("%d %d\n",feet,inch);
    return 0;
}

#include<stdio.h>
main()
{int n,inch,feet;
scanf("%d",&n);
feet=n/3;
if(n%3==2)
feet++;
printf("%d %d ",feet/12,feet%12);
return 0;
}

#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	scanf("%d",&a);
	b=a/3;
	c=a%3;
	if(c==2)
		b=b+1;
	d=b/12;
	e=b%12;
	printf("%d %d",d,e);
	return 0;
}

#include<stdio.h>
int main()
{
 int n,i;
 scanf("%d",&n);
  i=n%3;
  n=n/3;
  if(i==2)
  n++;
  printf("%d %d",n/12,n%12);
          return(0);
}

#include<stdio.h>
#define test 0.5

int main()
{
	double n,inch,temp;
	int feet;
	scanf("%lf",&n);
	inch = n/3;
	//printf("%lf\n",inch);
	feet = inch/12;
	inch = inch - (12*feet);
	//printf("%lf\n",inch);
	temp = inch - (int)inch;
	inch = (int)inch;
	//printf("%lf\n",temp);
	if(temp > test)
		inch += 1;
	if(inch == 12)
	{
		inch = inch-12;
		feet += 1;
	}
	printf("%d %.0lf\n",feet,inch);
	return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      n=(float)n/3+.5;
      f=n/12;
      i=n-12*f;
      printf("%d %d",f,i);
      return 0;
}

#include<stdio.h>
int main()
{
    int n,a,b,in,in2;
    scanf("%d",&n);
    in=n%3;
    in2=n/3;
    if(in==1)in=0;
    else if(in==2) in=1;
    a=in2/12;
    b=in2%12+in;
    a=a+b/12;
    b=b%12;
    printf("%d %d\n",a,b);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",(n+1)/36,(n+1)%36/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b;
    scanf("%d",&n);
    a = n/36;
    n %= 36;
    b = (n + 1)/3;
    if (b == 12)
    {
        a++;
        b = 0;
    }
    printf("%d %d",a,b);
    return 0;
}

#include <stdio.h>

int main(){
int n,d,f;
scanf("%d",&n);
if(n%3==0 || n%3==1) d=n/3;
else d=n/3+1;
f=d/12;
d=d%12;
printf("%d %d",f,d);
return 0;
}

#include<stdio.h>
int main()
{
    int n,r,m,a,b;
    scanf("%d",&n);
    r=n/3;
    a=n%3;
    if(a==1||a==0)
    {
        m=r;
    }
    else
    {
        m=r+1;
    }
    b=m/12;
    r=m%12;
    printf("%d %d",b,r);
    return 0;
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    if(inch==12){feet++;
        inch=0;}

    printf("%d %d\n",feet,inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch=0;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    inch=(cm/3);
    if(cm%3==2){inch++;};
    feet=inch/12;
    inch-=feet*12;
    printf("%d %d",feet, inch);
}

#include <stdio.h>

int main(void) {
	// your code goes here

	int n,i,j;
	scanf("%d",&n);
	j=n;
	n=n/3;
	i=j%3;
	if(i==1)i=0;
	else if(i==2) i=1;
	n=n+i;

	printf("%d %d",n/12,n%12);

	return 0;
}

#include<stdio.h>
//#include<conio.h>
int main()
 {
 int n,c,d,e;
 scanf("%d",&n);
 c=n%3;
 d=n/3;
 if(c==2) d++;
 e=d%12;
 d/=12;
 printf("%d %d",d,e);
 //getch();
 return 0;
 }

#include<stdio.h>

int main(void)
{
  int s, f;
  scanf("%d",&s);
  f = s / 3;
  if (s % 3 > 1) {
	  f++;
  }
  printf("%d %d\n", f / 12, f % 12);
  return 0;
}

#include<stdio.h>
int round(float);
main()
{
    int n;
    scanf("%d",&n);
    int f;
    int i=round(n/3.0);
    printf("%d %d",i/12,i%12);
    return 0;
}
int round(float k)
{
    int p;
    p=k;
    float t=k-p;
    if(t>=0.5) return (p+1);
    if(t<0.5) return (p);

}

//      Measuring Lengths in Baden.c
//
//      Copyright 2012 Administrator <cpy@ubuntu>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdio.h>

void func(int n)
{
	int a, b = 0;
	a = n / 36;
	n %= 36;
	b = n / 3;
	n %= 3;
	if (n == 2)
	{
		b ++;
		if (b >= 12)
		{
			a += (b * 3) / 36;
			b = b - (b * 3) / 36 * 12;
		}
	}
	printf("%d %d\n", a, b);
}

int main(int argc, char **argv)
{
	int n;
	while (scanf("%d", &n) == 1)
	{
		func(n);
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,inch;
    scanf("%d",&n);

    if(n%3==0||n%3==1)
    {
        inch=n/3;
    }

    else if(n%3==2)
    {
        inch=n/3+1;
    }
    feet=inch/12;
    inch=inch%12;
    printf("%d %d",feet,inch);
    return 0;

}

#include<stdio.h>
int main()
{
	int n, i,feet, inch, cen,k,r, t;
	scanf("%d", &cen);
	inch=cen/3;
	r=cen%3;
	if(r==2)
	{
		inch=inch+1;
	}
	//printf("%d\n", inch);
	feet=inch/12;
	inch=inch-(feet*12);

	printf("%d %d ",feet, inch);
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = 0;
    if(remainer >= 3){
        inches = remainer/3;
        remainer = remainer%3;
    }
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    if (inches >= 12) {
        feet += inches/12;
        inches = inches%12;
    }
    printf("%d %d\n", feet, inches);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{int a,b,c,d,e,f;
scanf("%d",&a);
b=a/3;
c=a%3;
if(c==2)
    {d=b+1;}
else
    {d=b;}
    e=d/12;
    f=d%12;
    printf("%d %d",e,f);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int d = (n + 1) / 3, f = d / 12;
    d -= f * 12;
    printf("%d %d", f, d);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    int d = (n + 1) / 3, f = d / 12;
    d %= 12;
    printf("%d %d", f, d);
    return 0;
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	if(num%36==35)
	a++;
	b=num-(a*36);
	c=b/3;
	if(b%3==2)
	{
		c++;
	}
	else
	c=c;

	printf("%lld %lld\n",a,c);
}

#include <stdio.h>

int main(int argc, char *argv[])
{
	int n;

	scanf("%d", &n);

	printf("%d %d\n", (n + 1) / 3 / 12, (n + 1) / 3 % 12);

	return 0;
}

#include<stdio.h>
#include<math.h>
#include <string.h>
#define N 100011

char str[N];

int main()
{
    int n;
    int a,b;
    while(scanf("%d", &n) != EOF) {
        a = n / 3;
        if(n % 3 >= 2) a++;
        b = a / 12;
        a %= 12;
        printf("%d %d\n", b, a);
    }
    return 0;
}

#include<stdio.h>

int main()
{
	int n;
	int feet,inches;

	while(scanf("%d",&n) != EOF) {
		n += 1;
		inches = n / 3;
		printf("%d %d\n",inches / 12 ,inches % 12);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(void){
int a ,b,c ;
div_t op;
scanf("%d",&a);

op=div(a,36);
b=op.quot;

op=div(op.rem,3);
c=op.quot;
if(op.rem==2){c=c+1;}
if(c==12){b++;
c=0;}
    printf("%d  ",b);
    printf("%d",c);
    return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (n % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (n % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include<stdio.h>

int main() {

	int n;
	int foot, inch;

	scanf("%d",&n);

	foot = n/36;

	inch = (n-foot*36 +1)/3;

	if (inch == 12) {
		foot++;
		inch = 0;
	}

	printf("%d %d\n", foot,inch);

	return 0;
}

#include<stdio.h>
int round(float);
main()
{
    int n;
    scanf("%d",&n);
    int i=round(n/3.0);
    printf("%d %d",i/12,i%12);
    return 0;
}
int round(float k)
{
    int p;
    p=k;
    float t=k-p;
    if(t>=0.5) return (p+1);
    if(t<0.5) return (p);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = (n+1) / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d",&n);
    b=n/3;
    if(n%3==2)
    ++b;
    a=b/12;
    b%=12;
    printf("%d %d",a,b);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
int cm,ft,inches;
scanf("%d",&cm);
inches=cm/3;
if(cm%3>1)
    inches++;
ft=inches/12;
inches=inches%12;

printf("%d %d",ft,inches);
//  system("Pause");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{

	int n;
	int feet;
	int inch;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

		scanf("%d", &n);

		feet = n / 36;
		inch = n % 36;

		inch = (inch + 1 )/3;

		if (inch == 12)
		{
			feet++;
			inch = 0;
		}
		printf("%d %d\n", feet, inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    // read number
    int cm;
    scanf("%d", &cm);

    // figure out feet
    int ft = cm/36;

    // figure out inches
    int inch_in_cm = cm - ft*36;
    int inches = inch_in_cm/3;
    int rem_inches = (inch_in_cm - inches*3) % 3;

    if (rem_inches > 1)
        inches++;

    // in case ft rounds up
    if (inches == 12)
    {
        inches = 0;
        ft++;
    }

    printf("%d %d\n", ft, inches);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int N,d,f;
  scanf("%d",&N);
  d = N/3;
  if(N%3>1){
		d++;
	}
	f = d/12;
	d = d - f*12;
	printf("%d %d\n", f, d);
  //system("PAUSE");
  return 0;
}

#include <stdio.h>

int main()
{
   int cm, feet, inch ;

   scanf("%d", &cm) ;

   for(inch=0; cm>1; ++inch)
        cm = cm - 3 ;

    for(feet=0; inch>=12; ++feet)
        inch = inch - 12 ;

   printf("%d %d", feet, inch);

    return 0 ;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int x;
    if(n%3 == 0 || n%3 == 1)
        x=n/3;
    else
        x=n/3+1;
    printf("%d %d", x/12, x%12);
    return 0;
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    if(inch==12)feet++;

    printf("%d %d\n",feet,inch);
}

#include<stdio.h>

int main()
{
    int n,feet,rem,inch;
    scanf("%d",&n);
    feet=n/36;
    rem=n%36;
    inch=rem/3;
    if(rem%3==2)inch++;
    printf("%d %d\n",feet,inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;

    scanf("%d", &cm);

    feet=cm/36;

    inch=(int)ceil((double)(cm%36)/3);

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    feet=cm/36;

    inch=(cm%36)/3;

    inch=(int)ceil((cm%36)/3.0) ;

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch;

    scanf("%d", &cm);

    feet=cm/36;

    inch=round((cm%36)/3);

    printf("%d %d",feet, inch);
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<math.h>

main()
{
    int i,j, cm, feet, inch=0;
                                                        //1 feet= 12 inc
    scanf("%d", &cm);                                   //1 inch = 3 cm

    feet=cm/36;

    inch=(cm%36)/3;
    if(cm%3==2){inch++;};

    printf("%d %d",feet, inch);
}

#include <stdio.h>

int main()
{
    int f,i,c;
    scanf("%d",&c);
    f=c/36;
    c=c%36;
    i=c/3;
    c=c%3;
    if(c==2)
    i++;
    printf("%d %d",f,i);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,inch;
    scanf("%d",&n);
    feet=n/36;
    n=n%36;

    if(n%3==0||n%3==1)
    {
        inch=n/3;
    }

    else if(n%3==2)
    {
        inch=n/3+1;
    }
    printf("%d %d",feet,inch);
    return 0;

}

#include<stdio.h>
int main()
{
    int n,r,f,i;
    scanf("%d",&n);
    r=n/3;
    n%=3;
    f=r/12;
    r%=12;

    if(n<2)
    n=0;
    else if(n>1)
    n=1;
    i=r+n;
    printf("%d %d",f,i);
}

#include<stdio.h>
int main()
{
	int n, i,feet, inch, cen,k,r, t;
	scanf("%d", &cen);
	inch=cen/3;
	r=cen%3;
	if(r==2)
	{
		inch=inch+1;
	}
	//printf("%d\n", inch);
	feet=inch/12;
	inch=inch%3;

	printf("%d %d ",feet, inch);
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	b=num-(a*36);
	c=b/3;
	if(b%3==2)
	{
		c++;
	}
	else
	c=c;

	printf("%lld %lld\n",a,c);
}

#include <stdio.h>
int main()
{
	long long int num,a,b,c;
	scanf("%lld",&num);
	a=num/36;
	b=num-(a*36);
	c=b/3;
	if(b%3==0)
	{
		c=c;
	}
	else
	c++;

	printf("%lld %lld\n",a,c);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp=0;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        temp==c%36;
    temp=i;
    i=temp/3;
    printf("%d %d",f,i);
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36==0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
    return 0;
}

#include <stdio.h>

int main()

{
    int i,f,c,temp;
    scanf("%d", &c);

    f=c/36;

    if(c%36!=0)
        c%36==temp;
    temp==i;
    i=temp/3;
    printf("%d %d",f,i);
    return 0;
}

#include<stdio.h>
#define test 0.5

int main()
{
	double n,inch,temp;
	int feet;
	scanf("%lf",&n);
	inch = n/3;
	//printf("%lf\n",inch);
	feet = inch/12;
	inch = inch - (12*feet);
	//printf("%lf\n",inch);
	temp = inch - (int)inch;
	inch = (int)inch;
	//printf("%lf\n",temp);
	if(temp > test)
		inch += 1;

	printf("%d %.0lf\n",feet,inch);
	return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      f=(float)n/36+.5;
      n=n-f*36;
      i=(float) n/3+.5;
      printf("%d %d",f,i);
      return 0;
}

#include<stdio.h>
main()
{
      int n,i,f;
      scanf("%d",&n);
      f=n/36;
      n=n-f*36;
      i=(float) n/3+.5;
      printf("%d %d",f,i);
      return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b;
    scanf("%d",&n);
    a = n/36;
    n %= 36;
    b = (n + 1)/3;
    printf("%d %d",a,b);
    return 0;
}

#include <stdio.h>
int main()
{
    int a,b,c,n;
    scanf("%d",&n);
    a=n / 36 ;
    c=n % 36;
    b=c / 3;
    if (c % 3 >= 2)
    {
        b++;}
    printf("%d %d",a,b);
    return 0;
}

#include<stdio.h>
int main()
{
 int n,i;
 float m;
 scanf("%d",&n);
 i=n/36;
 n=n%36;
 if(i==0)
 printf("0");
 else
 printf("%d",i);
         m=(float)n;
         m=m/3;
         n=n/3;
         if(m-n>0.5)
         printf(" %d",n+1);
         else
         printf(" %d",n);
          return(0);
}

#include<stdio.h>
int main()
{
	int S,N,K,T,Y;
	scanf("%d",&S);
	T=S;
	N=S/36;
	Y=S%36;
	S=S/36;
	if(T%3<2)
	K=(Y/3);
	else
	K=(Y/3)+1;
	printf("%d %d",N,K);
	return 0;
}

#include<stdio.h>
int main()
{
int n,feet,inch=0,t;
scanf("%d",&n);
feet=n/36;
t=n%36;
while(t>3)
{
t=t-3;
inch++;
}
if(t>=2)inch++;
printf("%d %d",feet,inch);
return 0;
}

#include<stdio.h>
int main()
{
long int n,feet,inch=0,t,p;
scanf("%ld",&n);
feet=n/36;
t=n%36;
inch=t/3;
p=t%3;
if(p>=2)inch++;
printf("%ld %ld",feet,inch);
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,n%36/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,(n%36+1)/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d %d",n/36,(n%36)/3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int s, d, f;
	scanf("%i",  &s);
	f = s / 36;
	d = (s - f*36) / 3;
	if ((s - f*36) - d*3 > 0) {
		d++;
	}
	printf("%d %d\n", f, d);
	return 0;
}

#include<stdio.h>
int main()
{
    int n,feet,tmp,inch;
    scanf("%d",&n);
    feet=n/36;
    tmp=n%36;
    inch=tmp/3;
    if(tmp%3==2)
                inch++;
    printf("%d %d\n",feet,inch);
    return 0;
}

//      Measuring Lengths in Baden.c
//
//      Copyright 2012 Administrator <cpy@ubuntu>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#include <stdio.h>

void func(int n)
{
	int a, b;
	a = n / 36;
	n %= 36;
	b = n / 3;
	n %= 3;
	if (n == 2)
	{
		b ++;
	}
	printf("%d %d\n", a, b);
}

int main(int argc, char **argv)
{
	int n;
	while (scanf("%d", &n) == 1)
	{
		func(n);
	}
	return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = 0;
    if(remainer >= 3){
        inches = remainer/3;
        remainer = remainer%3;
    }
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    printf("%d %d\n", feet, inches);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = remainer/3;
    remainer = remainer%3;
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    if (feet*36 + inches*3 < n) {
        inches++;
    }
    printf("%d %d\n", feet, inches);
    return 0;
}

#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int feet = n/36;
    int remainer = n%36;
    int inches = remainer/3;
    remainer = remainer%3;
    remainer = (remainer == 2) ? 1 : 0;
    inches += remainer;
    printf("%d %d\n", feet, inches);
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);
    printf("%d %d", n / 36, (n % 36 + 1) / 3);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(void){
int a ,b,c ;
div_t op;
scanf("%d",&a);

op=div(a,36);
b=op.quot;

op=div(op.rem,3);
c=op.quot;
if(op.rem==2){c=c+1;}
    printf("%d  ",b);
    printf("%d",c);
    return 0;
}

#include <stdio.h>

int main(void) {
	int n,a,b;
	scanf("%d", &n);
	b = n / 3;
	if (n % 3 == 2)
		b++;
	a = b / 12;
	printf("%d %d", a, b);
	return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (k % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (b % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include <stdio.h>

int main(void) {
    int n,a,b,k;
    scanf("%d", &n);
    k = n / 3;
    if (k % 3 == 2)
        k++;
    a =  k / 12;
    n -= 36*a;
    b = n / 3;
    if (n % 3 == 2)
        b++;
    printf("%d %d", a, b);
    return 0;
}

#include<stdio.h>

int main() {

	int n;
	int foot,inch;

	scanf("%d",&n);

	foot = n/36;

	inch = (n-foot*36 +1)/3;

	printf("%d %d\n", foot,inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = n+1 / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, a, b, c;
    scanf ("%d", &n);
    printf("%d ",a = n / 36);
    b = n - a * 36;
    c = b / 3;
    if (b - c * 3 > 1) c++;
    printf ("%d", c);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
int cm,ft,inches;
scanf("%d",&cm);
inches=cm/3;
ft=inches/12;
inches=inches%12;
if(cm%3>1)
    inches++;
printf("%d %d",ft,inches);
//  system("Pause");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{

	int n;
	int foot;
	int inch;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

		scanf("%d", &n);

		foot = n / 36;
		inch = n % 36;

		inch = (inch + 1 )/3;

		printf("%d %d\n", foot, inch);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    // read number
    int cm;
    scanf("%d", &cm);

    // figure out feet
    int ft = cm/36;

    // figure out inches
    int inch_in_cm = cm - ft*36;
    int inches = inch_in_cm/3;
    int rem_inches = (inch_in_cm - inches*3) % 3;

    if (rem_inches > 1)
        inches++;

    printf("%d %d\n", ft, inches);
    return 0;
}

#include <stdio.h>

int main()
{
	int n,g,h,i,j;
	scanf("%d",&n);
	g=n/36;
	h=n%36;
	i=h/3;
	j=h%3;
	if (j==2){
		i=i+1;
	}
	printf("%d %d",g,i);
	return 0;
}