/* ex4_2
   seira3 */

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

#define PI 3.141592653589793

int main(void){
    double lenA, lenB, hour, minute; //変数宣言
    scanf("%lf %lf %lf %lf",&lenA, &lenB, &hour, &minute); //入力
    double radA = (hour * 30 + minute * 0.5) * PI / 180; //12時のときの針と現在の短針のなす角(ラジアン)を宣言，代入
    double radB = minute * 6 *  PI / 180; //12時のときの針と現在の長針のなす角(ラジアン)を宣言，代入
    double diff = radA - radB; //短針と長針のなす角(ラジアン)を宣言，代入
    double ans = sqrt(lenA*lenA + lenB*lenB - 2*lenA*lenB*cos(diff)); //余弦定理より答えを宣言，代入(式変形はあたりまえ)
    printf("%-15.14lf\n",ans); //答えを出力
    return 0;
}