#include<stdio.h>
#include<math.h>
const double pi = acos(-1);
int main(){
    int a, b, h, m;
    int A, B;
    scanf("%d%d%d%d",&A,&B,&h,&m);
    a = A * A;
    b = B * B;
    int c = A * B * 2;
    int r = a + b;
    int p = 30 * h;
    int q = 6 * m;
    if(m % 2 == 0){
        m /= 2;
        int pp = p + m;
        int cc = pp - q;
        if(cc < 0)
            cc += 360;
        else if(cc > 180)
            cc = 360 - cc;
        printf("%5.15f\n",sqrt(r - c * cos(cc * pi / 180)));
        return 0;
    }
    m--;
    m /= 2;
    int pp = p + m;
    int cc = pp - q;
    if(cc < 0)
        cc += 360;
    else if(cc > 180)
        cc = 360 - cc;
    double x = (cc + 0.5) * pi / 180;
    double w = cos(x);
    double ans = r - c * w;
    printf("%5.15f\n",sqrt(ans));
    return 0;
}