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

double cos[360]={1,
0.999961923,
0.999847695,
0.999657325,
0.999390827,
0.999048222,
0.998629535,
0.998134798,
0.99756405,
0.996917334,
0.996194698,
0.995396198,
0.994521895,
0.993571856,
0.992546152,
0.991444861,
0.990268069,
0.989015863,
0.987688341,
0.986285602,
0.984807753,
0.983254908,
0.981627183,
0.979924705,
0.978147601,
0.976296007,
0.974370065,
0.97236992,
0.970295726,
0.96814764,
0.965925826,
0.963630453,
0.961261696,
0.958819735,
0.956304756,
0.953716951,
0.951056516,
0.948323655,
0.945518576,
0.942641491,
0.939692621,
0.936672189,
0.933580426,
0.930417568,
0.927183855,
0.923879533,
0.920504853,
0.917060074,
0.913545458,
0.909961271,
0.906307787,
0.902585284,
0.898794046,
0.894934362,
0.891006524,
0.887010833,
0.882947593,
0.878817113,
0.874619707,
0.870355696,
0.866025404,
0.86162916,
0.857167301,
0.852640164,
0.848048096,
0.843391446,
0.838670568,
0.833885822,
0.829037573,
0.824126189,
0.819152044,
0.814115518,
0.809016994,
0.803856861,
0.79863551,
0.79335334,
0.788010754,
0.782608157,
0.777145961,
0.771624583,
0.766044443,
0.760405966,
0.75470958,
0.748955721,
0.743144825,
0.737277337,
0.731353702,
0.725374371,
0.7193398,
0.713250449,
0.707106781,
0.700909264,
0.69465837,
0.688354576,
0.68199836,
0.675590208,
0.669130606,
0.662620048,
0.656059029,
0.649448048,
0.64278761,
0.63607822,
0.629320391,
0.622514637,
0.615661475,
0.608761429,
0.601815023,
0.594822787,
0.587785252,
0.580702956,
0.573576436,
0.566406237,
0.559192903,
0.551936985,
0.544639035,
0.537299608,
0.529919264,
0.522498565,
0.515038075,
0.507538363,
0.5,
0.49242356,
0.48480962,
0.47715876,
0.469471563,
0.461748613,
0.4539905,
0.446197813,
0.438371147,
0.430511097,
0.422618262,
0.414693243,
0.406736643,
0.398749069,
0.390731128,
0.382683432,
0.374606593,
0.366501227,
0.35836795,
0.350207381,
0.342020143,
0.333806859,
0.325568154,
0.317304656,
0.309016994,
0.3007058,
0.292371705,
0.284015345,
0.275637356,
0.267238376,
0.258819045,
0.250380004,
0.241921896,
0.233445364,
0.224951054,
0.216439614,
0.207911691,
0.199367934,
0.190808995,
0.182235525,
0.173648178,
0.165047606,
0.156434465,
0.147809411,
0.139173101,
0.130526192,
0.121869343,
0.113203214,
0.104528463,
0.095845753,
0.087155743,
0.078459096,
0.069756474,
0.06104854,
0.052335956,
0.043619387,
0.034899497,
0.026176948,
0.017452406,
0.008726535,
6.12574E-17,
-0.008726535,
-0.017452406,
-0.026176948,
-0.034899497,
-0.043619387,
-0.052335956,
-0.06104854,
-0.069756474,
-0.078459096,
-0.087155743,
-0.095845753,
-0.104528463,
-0.113203214,
-0.121869343,
-0.130526192,
-0.139173101,
-0.147809411,
-0.156434465,
-0.165047606,
-0.173648178,
-0.182235525,
-0.190808995,
-0.199367934,
-0.207911691,
-0.216439614,
-0.224951054,
-0.233445364,
-0.241921896,
-0.250380004,
-0.258819045,
-0.267238376,
-0.275637356,
-0.284015345,
-0.292371705,
-0.3007058,
-0.309016994,
-0.317304656,
-0.325568154,
-0.333806859,
-0.342020143,
-0.350207381,
-0.35836795,
-0.366501227,
-0.374606593,
-0.382683432,
-0.390731128,
-0.398749069,
-0.406736643,
-0.414693243,
-0.422618262,
-0.430511097,
-0.438371147,
-0.446197813,
-0.4539905,
-0.461748613
-0.469471563,
-0.47715876,
-0.48480962,
-0.49242356,
-0.5,
-0.507538363,
-0.515038075,
-0.522498565,
-0.529919264,
-0.537299608,
-0.544639035,
-0.551936985,
-0.559192903,
-0.566406237,
-0.573576436,
-0.580702956,
-0.587785252,
-0.594822787,
-0.601815023,
-0.608761429,
-0.615661475,
-0.622514637,
-0.629320391,
-0.63607822,
-0.64278761,
-0.649448048,
-0.656059029,
-0.662620048,
-0.669130606,
-0.675590208,
-0.68199836,
-0.688354576,
-0.69465837,
-0.700909264,
-0.707106781,
-0.713250449,
-0.7193398,
-0.725374371,
-0.731353702,
-0.737277337,
-0.743144825,
-0.748955721,
-0.75470958,
-0.760405966,
-0.766044443,
-0.771624583,
-0.777145961,
-0.782608157,
-0.788010754,
-0.79335334,
-0.79863551,
-0.803856861,
-0.809016994,
-0.814115518,
-0.819152044,
-0.824126189,
-0.829037573,
-0.833885822,
-0.838670568,
-0.843391446,
-0.848048096,
-0.852640164,
-0.857167301,
-0.86162916,
-0.866025404,
-0.870355696,
-0.874619707,
-0.878817113,
-0.882947593,
-0.887010833,
-0.891006524,
-0.894934362,
-0.898794046,
-0.902585284,
-0.906307787,
-0.909961271,
-0.913545458,
-0.917060074,
-0.920504853,
-0.923879533,
-0.927183855,
-0.930417568,
-0.933580426,
-0.936672189,
-0.939692621,
-0.942641491,
-0.945518576,
-0.948323655,
-0.951056516,
-0.953716951,
-0.956304756,
-0.958819735,
-0.961261696,
-0.963630453,
-0.965925826,
-0.96814764,
-0.970295726,
-0.97236992,
-0.974370065,
-0.976296007,
-0.978147601,
-0.979924705,
-0.981627183,
-0.983254908,
-0.984807753,
-0.986285602,
-0.987688341,
-0.989015863,
-0.990268069,
-0.991444861,
-0.992546152,
-0.993571856,
-0.994521895,
-0.995396198,
-0.996194698,
-0.996917334,
-0.99756405,
-0.998134798,
-0.998629535,
-0.999048222,
-0.999390827,
-0.999657325,
-0.999847695,
-0.999961923,
-1,
};
void main(){
    int a,b,h,m;
    double hd,md,ad;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    hd=30*h+0.5*m;
    md=6*m;
    if((ad=md-hd)>180){
        ad=ad-180;
    }
    if(ad=0){
        if(a>b)
        printf("%d",a-b);
        else
        printf("%d",b-a);
    }
    
    if(ad=180){
        if(a>b)
        printf("%d",a+b);
    }
    else{
    printf("&d",a*a+b*b-2*a*b*cos[(int)(ad/0.5)]);
    }
}