#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define	ll				long long
#define	db				long double
#define	vi				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set<int>
#define umap 			unordered_map<int,int>
#define pqbig 			priority_queue<int>
#define pqsmall			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;


ll prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (ll i = 2; i <= floor(sqrt(n)); i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{ 
	return !b ? a : gcd(b, a % b); 
}

int lcm(int a, int b)
{ 
	return (a / gcd(a, b)) * b; 
}

int fastExponentiation(int n, int x, int modulo) 
{
	int res = 1;
	while(x > 0) 
       {
          if(x & 1)
          res = (res*n) % modulo; 
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res; 
}

int power(int n , int p )
{
	if(p==0)
	   return 1;
 
	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;
 
	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}   

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i); 
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;
   	
   	else if(x>=n || y>=m)
       return false;
   	
   	else
   		return true;
}

bool comp(pair<int,int>&a,pair<int,int>&b)
{
	if(a.F==b.F)
		return a.S<=b.S;
	return a.F<b.F;
}

db 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;  

    db hour_angle = 0.5 * (h * 60 + m);  
    db minute_angle = 6 * m;  
 
    db angle = abs(hour_angle - minute_angle);  
 
    angle = min(360 - angle, angle);  
  
    return angle;  
}  

void solve()
{

	db a,b,h,m;
	cin>>a>>b>>h>>m;

	db angle=calcAngle(h,m);
	angle=(angle/(180.0))*PI;
	// cout<<(angle/(180.0))*PI<<endl;
	db c=abs(sqrt(a*a + b*b - 2*a*b*cos(angle)));

	cout<<c<<endl;

}	

int32_t main()
{
	fastio
	cout<<setprecision(20)<<fixed;

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif	

	// int t; cin>>t; while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 4192