#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file

using namespace __gnu_pbds;   //policy-based data structures (like set with adttional functionality) some operations 
//(*name.find_by_order(x) it givesyou value of x index in sorted set and name.find_by_key(no) it gives you the number at index no before sorting)

 typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds_s;




/* OHH..... BHAI MAARO... MUJHE MAARO.... JO MEIN ISS.. MAADHERCHOD CONTEST MEIN AAYA...*/






using namespace std;

#define ull                   unsigned long long	
#define ld                    long double
#define PI                    3.14159265358979323846264338327950L
#define substring             s.substr(form_index,to_which_index) //last index is not included
#define fastio                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                    long long int
#define deque                 deque<int> d; //dynamic array with push_front() ans pop_front functionality
#define PQ                    priority_queue<int> p; //max_heap stored data in decresing order
#define RPQ                   priority_queue<int,vector<int>,greater<int>> p; //min_heap in increasing order
#define decimalupto(no,y)     fixed<<setprecision(y)<<no
#define b_to_d(no)            bitset<32> ans("no");ans.to_ullong(); //when you have to make an array of binary array
#define d_to_b(no,upto)       bitset<upto> ans(no);ans.to_string(); //then you use bitset<int> name.And you can use operations (a&b),(a|b),(a^b)
#define inf                   1e9+5
#define mod                   1e9+7//1e9+7
#define count1(no)            __builtin_popcountll(no) //tells us the number of setbits means the total no. of 1 in a binary no.
#define count0_front(no)      __builtin_clz(no)// tells us the number of 0s in a binary no. from begiining
#define count0_back(no)       __builtin_ctz(no) //tells us the number of 0s from the count0_back
#define parity(no)            __builtin_parity(no)// tells the number is even or odd by counting the number of 1s 
#define Erase(i)              myvector.erase (myvector.begin()+i);//erase a specific element from a vector
#define grp_Erase(i)          myvector.erase (myvector.begin(),myvector.begin()+i); //erase the first i elemnts from a vector
#define copy array            copy(arr1.begin(), arr1.begin()+n, arr2.begin());
#define to_uppercase(s)       transform(s.begin(), s.end(), s.begin(), ::toupper);
#define to_lowercase(s)       transform(s.begin(), s.end(), s.begin(), ::tolower); 
#define gcd(a,b)              __gcd(a,b)
#define array_to_string       to_string(i) or string.push_back(arr[i]+'0')
#define string_to_int         s[i]-'a'
ll power(ll x,ll y,ll md=mod){
	ll res = 1;
	x%=md;
	while(y>0){
		if(y&1)res = (res*x)%md;
		x *= x;
		 if(x>=md) x %= md; y >>= 1;
		}
		return res;
	}

//#define left_operand(x<<y)    is equivalent to (x*2^y)
//#define right_operand(x>>y)   is equivalent to (x/2^y)

//int arr[100][100];


int main(){	
	
	   fastio // WHEN TAKE MOD THEN TAKE WITH (ll)mod  
	   int a,b,h,m;
	   cin>>a>>b>>h>>m;
	   ld angle = 2*PI*((ld)h/12+(ld)m/12/60-(ld)m/60);
	   ld ans = (ld)a*a+b*b-(ld)2*a*b*cos(angle);
	   cout<<decimalupto(sqrt(ans),20);

 }

 


	
	   
       



Measured memory_bytes: 4184