/*4_2 hightierra*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define PI 3.141592653589793
 
int main(void){
    int hhand,mhand,hour,minute;
    scanf("%d %d %d %d",&hhand,&mhand,&hour,&minute);

    double hhandangle,mhandangle,angledif,distance;
    
    // 短針と長針の角度から角度の差（ラジアン）を出す
    hhandangle = hour * 30 + minute * 0.5;
    mhandangle = minute * 6;
    angledif = fabs(hhandangle-mhandangle) * PI / 180.0;

    // 余弦定理
    distance = sqrt(pow((double)hhand,2.0) + pow((double)mhand,2.0) - 2.0*(double)hhand*(double)mhand*cos(angledif));

    printf("%.9lf\n",distance);

    return 0;

}