After waking up at hh:mm, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is H points, moreover each minute without food increases his hunger by D points.

At any time Andrew can visit the store where tasty buns are sold (you can assume that is doesn't take time to get to the store and back). One such bun costs C roubles and decreases hunger by N points. Since the demand for bakery drops heavily in the evening, there is a special 20% discount for buns starting from 20:00 (note that the cost might become rational). Of course, buns cannot be sold by parts.

Determine the minimum amount of money Andrew has to spend in order to feed his cat. The cat is considered fed if its hunger level is less than or equal to zero.


-----Input-----

The first line contains two integers hh and mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59) — the time of Andrew's awakening.

The second line contains four integers H, D, C and N (1 ≤ H ≤ 10^5, 1 ≤ D, C, N ≤ 10^2).


-----Output-----

Output the minimum amount of money to within three decimal digits. You answer is considered correct, if its absolute or relative error does not exceed 10^{ - 4}.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if $\frac{|a - b|}{\operatorname{max}(1,|b|)} \leq 10^{-4}$.


-----Examples-----
Input
19 00
255 1 100 1

Output
25200.0000

Input
17 41
1000 6 15 11

Output
1365.0000



-----Note-----

In the first sample Andrew can visit the store at exactly 20:00. The cat's hunger will be equal to 315, hence it will be necessary to purchase 315 buns. The discount makes the final answer 25200 roubles.

In the second sample it's optimal to visit the store right after he wakes up. Then he'll have to buy 91 bins per 15 roubles each and spend a total of 1365 roubles.

Difficulty: interview

Starter code:

Solutions:
from math import ceil

hh, mm = [int(x) for x in input().split()]

h, d, c, n = [int(x) for x in input().split()]

cost = 0.8 * c if hh >= 20 else c

res = int(ceil(h / n)) * cost

if hh < 20:
    diff = (20 - hh) * 60 - mm
    diff *= d
    h += diff
    res = min(res, int(ceil(h / n)) * 0.8 * c)
    
print(res)


import getpass
import sys
import math
from decimal import Decimal
import decimal

files = True
debug = False

if getpass.getuser() == 'frohenk' and files:
    debug = True
    sys.stdin = open("test.in")
    # sys.stdout = open('test.out', 'w')
elif files:
    # fname = "gift"
    # sys.stdin = open("%s.in" % fname)
    # sys.stdout = open('%s.out' % fname, 'w')
    pass


def lcm(a, b):
    return a * b // math.gcd(a, b)


def ria():
    return [int(i) for i in input().split()]


def range_sum(a, b):
    ass = (((b - a + 1) // 2) * (a + b))
    if (a - b) % 2 == 0:
        ass += (b - a + 2) // 2
    return ass


def comba(n, x):
    return (math.factorial(n) // math.factorial(n - x)) // math.factorial(x)


h, m = ria()
time = h * 60 + m
offerTime = max(20 * 60 - time, 0)

h, d, c, n = ria()
mini = math.ceil(h / n) * c

h+=offerTime*d

mini = min(math.ceil(h / n) * c*0.8,mini)
print(mini)


h,m = map(int, input().split())
k,d,c,n =map(int, input().split())
from math import ceil
if h >= 20:
    print(ceil(k/n)*(c*0.8))
else:
    a1 = ceil(k/n)*c
    r = 60*(20-h) - m
    a2 = (ceil((k+r*d)/n))*(c*0.8)
    print(min(a1,a2))

hh, mm = [int(v) for v in input().split()]
H, D, C, N = [int(v) for v in input().split()]

def dvru(a, b):
    return (a + b - 1) // b

if hh >= 20:
    print(dvru(H, N) * (C * 0.8))
else:
    c1 = dvru(H, N) * C
    t = (20 - hh - 1) * 60 + (60 - mm)
    c2 = dvru(H + t * D, N) * (C * 0.8)
    print(min(c1, c2))


from math import ceil
h, m = list(map(int, input().split()))
H, d, c, n = list(map(float, input().split()))
if h >= 20:
    print(round(ceil(H / n) * c * 0.8, 3))
else:
    print(round(min(ceil(H / n) * c, ceil(((20 * 60 - h * 60 - m) * d + H) / n) * c * 0.8), 3))


from math import ceil
h,m = list(map(int,input().split()))
H,D,C,N = list(map(int,input().split()))

diff = max(0,20*60 - (h*60+m))

ans = min( ceil(H/N)*C, ceil((H+diff*D)/N)*0.8*C )

print(ans)


hh, mm = list(map(int, input().split()))
curminutes = hh * 60 + mm

h, d, c, n = list(map(int, input().split()))

cost_now = ((h + n - 1) // n) * c

thenminutes = 20 * 60
if thenminutes <= curminutes:
    print(cost_now * 0.8)
else:
    hunger_then = (thenminutes - curminutes) * d + h
    # print('now', cost_now)
    print(min(cost_now, (hunger_then + n - 1) // n * c * 0.8))


def f(a,b):
    if  a % b == 0:
        return a // b
    else:
        return a // b + 1

hh,mm = map(int,input().split())
h,d,c,n = map(int,input().split())
t = hh * 60 + mm
if t >= 20 * 60:
    print(c * f(h,n) * 0.8)
else:
    print(min(c * f(h,n),c * 0.8 * f((20 * 60 - t) * d + h,n) ))

import math
h, m = list(map(int,input().split()))
H,D,C,N = list(map(int,input().split()))
mn = (20-h)*60-m
if mn < 0: mn = 0
a1 = C*math.ceil(H/N)
a2 = C*0.8*math.ceil((H+mn*D)/N)
print(min(a1,a2))


def div(a, b):
    return a // b + int(a % b != 0)

hh, mm = list(map(int, input().split()))
h, d, c, n = list(map(int, input().split()))
wait = 0
if hh < 20:
    wait = 60 * (20 - hh - 1) + 60 - mm
print(0.2 * min(div(h, n) * c * 5, div(wait * d + h, n) * c * 4))


h, m = list(map(int, input().split()))
H, D, C, N = list(map(int, input().split()))
after = C * 0.8
ans = (H + N - 1) // N * C
tm = h * 60 + m
tm1 = 20 * 60 + 0
tm2 = 23 * 60 + 59
if tm1 <= tm <= tm2:
    print('{:.16f}'.format((H + N - 1) // N * after))
else:
    tm3 = tm1 - tm
    print('{:.16f}'.format(min(ans, (H + N - 1 + D * tm3) // N * after)))


hh, mm = list(map(int, input().split()))

h, d, c, n = list(map(int, input().split()))

if hh >= 20:
	c *= 0.8
	cost1 = cost2 = (h + n - 1) // n * c
else:
	cost1 = (h + n - 1) // n * c
	h += (20 * 60 - hh * 60 - mm) * d
	c *= 0.8
	cost2 = (h + n - 1) // n * c

print('{:.10f}'.format(min(cost1, cost2)))


import math
arr=list(map(str,input().strip().split(' ')))
n=int(arr[0])
t=int(arr[1])

h,d,c,nn= (list(map(int,input().strip().split(' '))))
if(n>=20):
  price=.8*c*math.ceil(h*1.0/nn*1.0)
  print(price)
else:
  hunger = (20*60-n*60-t)*d+h
  # print(hunger,(20*60-n*60-t)*d,h,n)
  price=min(.8*c*math.ceil(hunger*1.0/nn*1.0),math.ceil(h*1.0/nn*1.0)*c)
  print(price)


from math import gcd, floor, ceil
from random import randrange
def li():
    return list(map(int, input().split()))
h, m = li()
cur, d, c, n = li()
if 60 * h + m < 20 * 60:
    an = ((cur + n - 1) // n) * c
    cur += (20 * 60 - 60 * h - m) * d
    c *= 0.8
    an = min(an, c * ((cur + n - 1) // n))
else:
    c *= 0.8
    an = c * ((cur + n - 1) // n)
print(an)


h, m = map(int, input().split());
g, u, s, k = map(int, input().split());
d20 = ((g + k - 1) // k) * s;
v = (20 - h - 1) * 60 + (60 - m);
if v < 0:
    v = 0;
s2 = s - s / 5;
p20 = ((g + v * u + k - 1) // k) * s2;
print(min(d20, p20));

hh, mm = map(int, input().split())
h, d, c, n = map(int, input().split())
x = (h + n - 1) // n * c
y = (h + d * max(0, 20 * 60 - (hh * 60 + mm)) + n - 1) // n * c * 0.8
print(min(x, y))

h, m = list(map(int, input().split()))
cur, d, c, n = list(map(int, input().split()))
ans = (cur // n)* c
if (cur%n!=0):
    ans+=c
time = h * 60 + m
if (time < 20*60):
    cur += d*(20*60 - time)
ans1 = (cur//n)*0.8*c
if (cur%n!=0):
    ans1+=0.8*c
ans = min(ans, ans1)
print("%.4f" % ans)


R = lambda : list(map(int, input().split()))

hh,mm = R()
h,d,c,n = R()

import math
cb = math.ceil((h*1.0)/n)*c

mn = hh*60+mm
e = 20*60

dp = c*0.8

if (mn<=e):
    nh = h+d*(e-mn)
    cb = min(cb,math.ceil((nh*1.0)/n)*dp)
else:
    cb = cb*0.8

print(cb)


from math import ceil
h, m = list(map(int, input().split()))
H, D, C, N = list(map(int, input().split()))
if h >= 20:
    print(0.8 * C * ceil(H / N))
else:
    minutes = 20 * 60 - h * 60 - m
    no_wait = C * ceil(H / N)
    with_wait = 0.8 * C * ceil((H + D * minutes) / N)
    print(min(with_wait, no_wait))


import math

to_min = lambda h, m: h * 60 + m

hh, mm = list(map(int, input().split()))
h, d, c, n = list(map(int, input().split()))

t = to_min(hh, mm)
dt = to_min(20, 0)

if t < dt:
    dh = ((dt - t) * d) + h
    dp = math.ceil(dh/n)
    p = math.ceil(h/n)
    print(min(0.8*dp*c, p*c))
else:
    print(0.8*c*math.ceil(h/n))


h,m = list(map(int,input().split()))
hu,d,c,n = list(map(int,input().split()))
if h >= 20:
    if hu % n != 0:
        hu = hu + n-hu%n
    print((hu*4*c)/(5*n))
else:
    lhu = hu
    p = float('inf')
    if hu % n != 0:
        hu = hu + n-hu%n
    p = min(p,hu*c/n)
    #print(p)
    hu = lhu+((19-h)*60+(60-m))*d
    if hu % n != 0:
        hu = hu + n-hu%n
    p = min(p,(hu*c*4)/(5*n))
    print(p)


hour, minut = map(int, input().split())
h, d, c, n = map(float, input().split())
time = hour * 60 + minut
ind = 0
ans = 100000000000000000000000000000000000000000000000000000
while time < 24 * 60:
    hungr = h + ind * d
    if time >= 20 * 60:
        price = c * 0.8
        if hungr % n == 0:
            a = (hungr // n) * price
        else:
            a = (hungr // n + 1) * price
    else:
        price = c * 1
        if hungr % n == 0:
            a = (hungr // n) * price
        else:
            a = (hungr // n + 1) * price
    if a < ans:
        ans = a
    time += 1
    ind += 1
print(ans)

from math import ceil

hh, mm = list(map(int, input().split()))
H, D, C, N = list(map(int, input().split()))

time_now = 60 * hh + mm
time_sale = 60 * 20

d_time = time_sale - time_now
c = 0.8 * C

if d_time <= 0:
    print('{:.4f}'.format(ceil(H / N) * c))

else:
    print('{:.4f}'.format(min(ceil(H / N) * C, ceil((H + D * d_time) / N) * c)))


import math
hh,mm = [int(x) for x in input().split()]
h,d,c,n = [int(x) for x in input().split()]
if hh>=20:
    print(0.8*c*math.ceil(h/n))
else:
    print(min(0.8*c*math.ceil(((((20-hh)*60-mm)*d)+h)/n),c*math.ceil(h/n)))