let n = readLine()!.split(separator: " ").map{Int($0)!} var (a,b,c,d,e) = (n[0],n[1],n[2],n[3],n[4]) var m = a * (b - c) var s = 0 for i in 0...m{ if (i + 1) % 10 > 0{ s += d }else if d < e{ s += d }else{ s += d - e d -= e } } print(s)