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 day=sc.nextInt();
        int juan=sc.nextInt();
        if(month==11&&day==11)
        {
            price=price*0.7-juan*50;
        }else if(month==12&&day==12)
        {
            price=price*0.8-juan*50;
        }
        if(price<0)
        {
            price=0;
        }
        System.out.printf("%.2f",price);
    }
}