#include <stdio.h>

int main() {
    int b, c, d;
    double a, goal;
    while (scanf("%lf %d %d %d", &a, &b, &c, &d) != EOF) {
        if (b == 12 && c == 12) {
            goal = a * 0.8;
            if (d == 1) {
                goal -= 50;
            }
        }
        if (b == 11 && c == 11) {
            goal = a * 0.7;
            if (d == 1) {
                goal -= 50;
            }
            if(goal<=0)
            {
                goal=0;
            }
        }

        printf("%.2f", goal);
    }
    return 0;
}