import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNext()) {
double oldPrice = Double.parseDouble(scan.next());
int month = Integer.parseInt(scan.next());
int day = Integer.parseInt(scan.next());
int isBargar = Integer.parseInt(scan.next());
double newPrice = oldPrice;
if(month == 11 && day == 11 || month == 12 && day == 12) {//判断日期是否为双11或双12
double discount = month == 11 ? 0.7 : 0.8;//双11和双12折扣不同
newPrice *= discount; //打完折后的价格
if(isBargar == 1) {//如果有优惠券,还需要再减去50
newPrice -= 50;
}
}
System.out.printf("%.2f", Math.max(newPrice, 0));//注意,最终价格不可能低于
}
}
}