#include <stdio.h>
#include <math.h>
int n;
double factorial(n) {
    if (n == 0) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}

int main() {
    double x;
    int n,i;
    double cos_approx = 0;

    scanf("%lf %d", &x, &n);

    for (i = 0; i <= n; i++) {
        double term = pow(-1, i) * pow(x, 2 * i) / factorial(2 * i);
        cos_approx += term;
    }

    printf("%.8f\n", cos_approx);

    return 0;
}
