/*
    ──────────────────────────────░░░────────
    ───────────────────────────░▓█████▒──────
    ──────────────────────────░████████▒─────
    ─────────────────────────░██████████░────
    ─────────────────────────███████████▓────
    ────────────────────────░████████████────
    ────────────────────────█████████████▒───
    ───────────────────────░█████████████▓───
    ───────────────────────▓██████████████───
    ───────────────────────███████████████───
    ───────────────────────█████▓█████████░──
    ──────────────────────░████▓▓█████████░──
    ───────────────────────███▓▓▓▓▓███▓▓██▒──
    ───────────────────────████▓▓▓▓▓▓▓▓▓██▒──
    ───────────────────────████▓▓▓▓▓▓▓▓▓██▒──
    ───────────────────────████▓▓▓▓▓▓▓▓▓██▒──
    ──────────░░░───░░░▒▓▓▓███▓▓▓▓▓▓▓█████░──
    ─────────░████████████████▓▓██████████░──
    ──────────████████████████▓▓██▓▓▓█████░──
    ──────────██▓▓████████████▓████▓▓█████░──
    ────────▓▓█▓▓▓▓▓██████████▓███████████░──
    ────────██▓▓▓▓█▓█████▓▓▓██▓████▓▓█████░──
    ────────░█▓▓█▓█████────░██▓████▓▓█████░──
    ────────▓█▓▓▓▓▓▒█▒▓─────██▓█▓██▓▓█████░──
    ───────░██▓▓▓▓█░█▒░░────███▓▓▓▓▓▓█████░──
    ───────██▓▓▓███▓▓█▓░────▓██▓▓▓█▓▓▓███▓───
    ──────███▓▓▓▓▓████░─────▒██▓▓▓█▓▓▓███▒───
    ─────▓███▓▓▓▓▓██────────░███▓▓███████▒───
    ────░██▓▓▓██▓▓██─────────░███████████▒───
    ───░██▓▓▓███▓▓██─────────░███████████▒───
    ───████▓████▓██▓──────────███████████░───
    ──█████▓██▓▓▓██▓──────────███████▓███────
    ─███▓██████████▓──────────▓███▓▓████▓────
    ─██▓▓████▓█████▓──────────▒█████████░────
    ░██▓▓███──██████──────────▓█████████─────
    ▒██▓▓▓██──░███▒░─────────░██████████─────
    ▓██▓▓██▓─────────────────███████████─────
    ███████▒────────────────▓█▓▓████████▒────
    ███████░─────────░░░──░▓██▓▓▓██████▓█────
    ███████─────▓█████████████▓▓▓█████▓▓█▓───
    ██████▓────░██████████████▓▓▓▓████▓▓██▒──
    ██████▒────▒███████████████▓▓▓▓██▓▓▓████░
    ██████░────▓███████████████▓▓▓▓██▓▓▓█████
    ██████─────████████████████▓▓▓████▓▓▓████
    ██████────░███████████████▓▓▓▓████▓▓▓████
    █████▓───░████████████████▓▓▓██████▓▓████
    █████▒───█████████████████▓▓▓██████▓▓████
    █████──▒██████████████████▓▓█▓▓██▓██▓████
    ████▓─░███████████████████▓▓▓▓▓██▓▓██████
    ████▒─████████████████████▓▓▓▓▓██▓▓▓█████
    ████▓▓████████████████████▓▓▓▓▓██▓▓▓█████
    ██████████████████████████▓▓▓▓▓██▓▓▓█████
    ██████████████████████████▓▓▓▓▓██▓▓▓█████
    ██████████████████████████▓▓▓▓███▓▓▓█████
    ██████████████████████████▓▓▓▓███▓▓▓█████
    ██████████████████████████▓▓▓▓████▓▓█████
    ██████████████████████████▓▓▓▓████▓▓█████
    ██████████████████████████▓▓▓▓████▓▓█████
    ██████████████████████████▓▓▓▓████▓▓█████
    ██████████████████████████▓▓▓▓████▓▓█████
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define se second
#define fi first 
//ll a[1000007];

double calcAngle(double h, double m)  
{  
    // validate the input  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    // Calculate the angles moved  
    // by hour and minute hands  
    // with reference to 12:00  
    double hour_angle = 0.5 * ((double)h * 60 + (double)m);  
    double minute_angle = 6 * (double)m;  
  
    // Find the difference between two angles  
    double angle = abs((double)hour_angle - (double)minute_angle);  
  
    // Return the smaller angle of two possible angles  
    angle = min(360 - (double)angle, (double)angle);  
  
    return angle;  
}

double cal_cos(double n) 
{ 
    double accuracy = 0.00000000001, x1, denominator, cosx, cosval; 
  
    // Converting degrees to radian 
    n = n * (3.141592653589793 / 180.0); 
  
    x1 = 1; 
  
    // Maps the sum along the series 
    cosx = x1; 
  
    // Holds the actual value of sin(n) 
    cosval = cos(n); 
    int i = 1; 
    do { 
        denominator = 2 * i * (2 * i - 1); 
        x1 = -x1 * n * n / denominator; 
        cosx = cosx + x1; 
        i = i + 1; 
    } while (accuracy <= fabs(cosval - cosx)); 
  
    return cosx; 
} 
  
// Function to find third side 
double third_side(int a, int b, double c) 
{ 
    double angle = cal_cos(c); 
    return sqrt((a * a) + (b * b) - 2 * a * b * angle); 
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i, k, l, t, n, sum, r, m, y, j;
	
	cin>>i>>j>>k>>l;
	double x = calcAngle(k,l);
	//cout<<third_side(i,j,x);
	cout<<fixed<<setprecision(10)<<third_side(i,j,x);
}
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMHBYYYWMMMM#BYYTTTYWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMB9O1==?????zzCC111>>;;;;;;;;;;;<?TMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM9Olll=l======??????????>>>>>>;;;;;;;;;:;?TMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMMMM9ttlllllllll=l=======?????????>>>>>>;;;;;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMMMBOttOtttttltlllllllll=======??????????>>>>>>>;;;;;;?TMMMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMMMBttwOtttttttttttttlllllllll========?????????>>>>>>;;;;;<TMMMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMMBrwZrttttttttttttttttttlllllllllll======???????????>>>>>>;;?HMMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMMSw0trtrrtrtrttrtttttttttttttlllOllllll========????<<zz??>>>>>>ZMMMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMMMX0ttrtrOOttrttrttOOttttttttttttltwllllllllll========??wy?????>>>vZMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMM0ttrI+wV1rtttttttwZtttttttltttOwylOXOllllllllllll=l====1dkz???????vZdMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMSrrwrtwZCjttttttttwSttOlllltllllwtXOlZkOlllllllllllllll==z+dk===?????X2JMMMMMMMMMMMMM
//  MMMMMMMMMMMMMBrtwwtrw0<jttttttttOXllOttltllttllOZwHOtXkyltlllllllllllllll<+XZ======?dk?JMMMMMMMMMMMM
//  MMMMMMMMMMMMStwdZtwXC<+ttttttOOOd6ltZlltllllttllStWWOOHWytttttltltOllltllz:zHllll===zX=?dMMMMMMMMMMM
//  MMMMMMMMMMBrwdKOtwW3;;zrttttwZwXRlldOllltltlltttwlXvktdXWytltttttttOttlttl<<dklllllllZ===dMMMMMMMMMM
//  MMMMMMMMM8tQM#ttwW3;;;1trttwSwfUOlORltllltlllllldtX>dktDOWOtlttltttOOttltO<;+WOllllllXlllzMMMMMMMMMM
//  MMMMMMMM9OdM#Ottd$;;;;;<?1z0OKjRltd0llltOllllllldZX>?WOw_WWOtttttttttOttI<;;<dkttttllllllldMMMMMMMMM
//  MMMMMMM9wMMMSttwS<;;;;>;;;J<j>(I<?U111zltllllllld0X>~dkwl(WkttlttlOOwWk<;;:;;zHttttttwOllllMMMMMMMMM
//  MMMMMMBdMMM8tttdI+zttttttdSXt~dlzXwlllzzOzzzzzlldkW<~?kOk~?sx++++jdHmH6+++<;;jdZtttttdkOtlldMMMMMMMM
//  MMMMM#dMMM#tttw0+tttttttdKdf((RsdfRllllldZllltlldWK~~_W0w_~OWOlOdgg9ZtOWOtttz+wktttttdpktttwMMMMMMMM
//  MMMMMWMMMMSlttdIttttttOdWHH>~(IzWDRll=llzRlllzlldk$>++dkd<~_XkdgH9tttttdktttt+OkrttrtdfpkttOMMMMMMMM
//  MMMMNWMMM#Zttlk=tttttOXWWd$_.(IdW1R=llll=SlllzOldK<_._(kd6+-(MM9lltttttrWktttztWZttrwXppWttrMMMMMMMM
//  MMMMNMMMM#lltwDzttllOXyW0X:..(OXk<Rl=ll=lwOlllOld3<``.(Rd>~?CdklllltttttXdXttzOWktrwwWpfpkrtMMMMMMMM
//  MMMMMMMMM@ltldIzlttOXyW$w$```(OyD(Rl==llldZ=llIlw;~```-Xd:~~~~UkylltttAyHdgSrzObRtOXwpfppWrrMMMMMMMM
//  MMMMMMMMM@llldtlllldVyW+d>```.wZ$ wl==lI=wRl=ll=w<```` dd_..~~(RZXOQdggHH9ZwrzwHWrdXXppfppkrMMMMMMMM
//  MMMMMMMMM#llldlltlwyyyD(S-...,Wk] zI=l=llzWzl=l=P~```` jZ``...~zQkH@MBUtrZtrtldHRdSdpfpffpkwMMMMMMMM
//  MMMMNMMMMNZllXtllldVyW3(Mf=<ONMHP~(k===l=zdk=lld3```...(C````..(M96lttttrrtrrtdHWHXpfpppfpRwMMMMMMMM
//  MMMMMMMMMMNzzWZllzyyyy(W@`  =~MWK6 jz=lzlzvRz=lZ`.I+JgkWm&-. `..(ZltlttttrtttrWWHppfppfpppSdMMMMMMMM
//  MMMMMMMMMMMkAWRllzVyyS_(b    .MNHU-(Uz=lI={XkzO>.dVT7<TMHMNHHx-.(kwZyltttrtrrdHHpfppfpffpp0dMMMMMMMM
//  MMMMMMMMMMMMKyWzOzyyyk.`<!  hdWMH]``(S==t=l(kX2 ?_`    WMMHH#HH+.XwkwOttttrwrZ~(HfpfpppfpWwXMMMMMMMM
//  MMMMMMMMMMMMMHWROOyyyW;` `. (WVM#b```(0=zzz wX!```  a.dM#NM@N(4WhXkXkWtttttwd3O_(HpffpfpfWwSMMMMMMMM
//  MMMMMMMMMMMMNZvWzXXyyXP```-_ ?o+?!````.4=Z=`(:````  HpbNNMHHH (C=XXyWZWttrdwf:(>.dfppffppSXSMMMMMMMM
//  MMMMMMMMMMMMMRzuHzXyZXH.``````````````` ?zz ``````` ZKvTHHbWt `` XZyyHZWOdSZ<::~`(fpfpfffXp0WMMMMMMM
//  MMMMMMMMMMMMMKzyyHvyZZW____.`````````````.I_```````` ?nJzX7^````.WXWyyHyWKZ<:::_`Jffpfpfpfp0WMMMMMMM
//  MMMMMMMMMMMMM@zZyZWwWyXo-_~(~ ```````````` `````````````` _`````.WXkyyVWmWc::<~ .HffppfffffkXMMMMMMM
//  MMMMMMMMMMMMMKzZZZZXkUXr~....```````....```````````` ...  ````..JXWWyyW83vXx~..WfffVfWVffffkdMMMMMMM
//  MMMMMMMMMMMMMRzZZZZZZZZb````````````<````````````./<~._<_.____`(WfdyW3<:~~(XWkVVVVVVVHVVVVV0dMMMMMMM
//  MMMMMMMMMMMMMSzZZZZZZZWX-```````````````````````````.......~~._j9jX=_~~_(XZyVHHkyyyyWHyyykykOMMMMMMM
//  MMMMMMMMMMMMMSzuuuuuZXWZW,```````````````````````````````.``..(3<! ...JWyyXWyyyWHkyyWHyyyHyklMMMMMMM
//  MMMMMMMMMMMMNXzuuuXXuXSuuXh,```````` .... ```````````````````_~ .JWyyyyZyy0HyyZyyZyZXWZZZWHZIdMMMMMM
//  MMMMMMMMMMMMNwtuuuXkuXXuuuuXh,``````(:::~<?71(,``````````````.(UMNUkZZZZZZZHZZ0ZZZZZWWZZZWNXIdMMMMMM
//  MMMMMMMMMMMMNKOzuzXkuXuuuuuXuXW, ```` _~~~:~~(}```````````.(YC;::<kCfZZZZXO#ZZVZZZZZMZZuuMMNXzMMMMMM
//  MMMMMMMMMMMMHKOzzuXkzdzzzzuXXzuuU&.``````````````````` .JY>::::;;J=:dZuZuZd#uuruuuud#uuuXMMMNXdMMMMM
//  MMMMMMMMMMMMMNOvzzXkvMRzzzzXKzuzzzXh, `````````````..JC<;:;;:;;+7<:~(HHuXIdNuuzuuuXMSuuuWMMMMROMMMMM
//  MMMMMMMMMMMMMNvvvrdkvM#vzzzzHzzzzzuzzUG. ``` ...JdY<:;:;:::;;+v<~~~:(HpHmzMNXZzuzzd#zzzdMMMMMMRdMMMM
//  MMMMMMMMMMMMMNwrrvdRrMNwvvvvdRvvvzwkzzzzXWWHY=~~O+::::::::<+<~~~~~~~dppppWMMkZzzzwM#zzdMMMMMMMMNMMMM
//  MMMMMMMMMMMMMM#rrrwRrMMbOrrOZNkrvvvXwvvvvvwX;.~._W_:::::(?!~~~~~~~~(HpppppppHWdvwM#XwdMMMMMMMMMMNMMM
//  MMMMMMMMMMMMMMNyrrrRrWMMmzOrzdNyrrrZNvrwQWWfb....(r~~_J>_.....~.~~-dpfpffpfpppWHHMNdMMMMMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMNrtrStdMMMNxzrzMNmrrrdNWfVfffP._-.(~_J!............JpfpffpfpfffpppWNppppHMMMMMMMMMMMM
//  MMMMMMMMMMMMMMMMNOtXtdMMMMMNxzZMMNmgHyVVVVVW%..?/(.,(x-..........(HfffpffpffpffWHHffpffppfVyyWMMMMMM

Measured memory_bytes: 4276