#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

const long double PI = 3.14159365358979323846264338327950288L;

long double div12(int H)
{
    int div = 12;
    for (int c = 0; c < 2; ++c)
    {
        if (H % 2 == 0)
        {
            div /= 2;
            H /= 2;
        }
    }
    if (H % 3 == 0)
    {
        div /= 3;
        H /= 3;
    }
    return ((long double)H) / div;
}

long double div60(int H)
{
    int div = 60;
    for (int c = 0; c < 2; ++c)
    {
        if (H % 2 == 0)
        {
            div /= 2;
            H /= 2;
        }
    }
    if (H % 3 == 0)
    {
        div /= 3;
        H /= 3;
    }
    if (H % 5 == 0)
    {
        div /= 5;
        H /= 5;
    }
    return ((long double)H) / div;
}

long double div720(int H)
{
    int div = 720;
    for (int c = 0; c < 4; ++c)
    {
        if (H % 2 == 0)
        {
            div /= 2;
            H /= 2;
        }
    }
    for (int c = 0; c < 2; ++c)
    {
        if (H % 3 == 0)
        {
            div /= 3;
            H /= 3;
        }
    }
    if (H % 5 == 0)
    {
        div /= 5;
        H /= 5;
    }
    return ((long double)H) / div;
}

int main(void)
{
    int A, B, H, M;
    long double theta, ans;
    scanf("%d %d %d %d", &A, &B, &H, &M);
    theta = 2 * PI * (div12(H) + div720(M) - div60(M));
    ans = sqrtl(A * A + B * B - 2 * A * B * cosl(theta));
    printf("%20.20llf\n", ans);
    return 0;
}