import java.util.Scanner;
public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        double price = sc.nextDouble();
        int month = sc.nextInt();
        int date = sc.nextInt();
        int you = sc.nextInt();
        if(month == 11 && date == 11) {
            price = 0.7 * price - you * 50;
        } else if(month == 12 && date == 12) {
            price = 0.8 * price - you * 50;
        }
        if(price < 0) {    // 提示:不要指望商家倒找你钱
            price = 0;
        }
        System.out.println(String.format("%.2f",price));
    }
}