#include <stdio.h>
int main() 
{
	int month,day,fact;
	double price;
	scanf("%lf %d %d %d",&price,&month,&day,&fact);
	if(month==11&&day==11)
	{
		price=price*0.7;
		if(fact==1)
		price=price-50;
	}
	else if(month==12&&day==12)
	{
		price=price*0.8;
		if(fact==1)
		price=price-50;
	}
	if(price<0)
	price=0.0;
	printf("%.2lf",price);
	return 0;
}