//////////////      VATSAL AGARWAL       ////////////////////////
////////////// Codeforces id : warhead38 ////////////////////////
////////////// Codechef   id : vatsal38  //////////////////////// 


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define endl '\n'
#define loop(a,b,c) for(ll i=a;i<=b;i+=c)
#define intarr(arr,n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i]
#define inparr(arr,n) for(ll i=0;i<n;i++)cin>>arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define newline cout<<endl
#define ump unordered_map<ll,ll>
#define vec vector<ll>
#define mkp make_pair
#define disp(var1,var2) cout<<var1<<" "<<var2<<endl;
#define all(v)             v.begin(),v.end()
#define cout(var) cout<<var<<endl
#define mod2 998244353
#define fbo find_by_order  /// find kth smallest by passing k-1
#define ook order_of_key  //// find no of smaller items less than k
#define teensort(a,r,g,b) a[0]=r;a[1]=g;a[2]=b;sort(a,a+3);
#define ss second
#define ff first
#define displayarray(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
#define pi pair<ll,ll>
#define meramax 1e18
#define meramin -1e18
#define percentile 1000000007
#define PI 3.14159265358979323846

ll calcsum(auto a,ll n)
{
    ll sum=0;
    for(ll i=0;i<n;i++)
        sum+=a[i];
    return sum;
}

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll power(ll x,ll y) 
{ 
    ll temp; 
    if(y==0) 
        return 1; 
    temp=power(x,y/2); 
    if (y%2==0) 
        return temp*temp; 
    else
        return x*temp*temp; 
} 

ll no_of_factors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 

ll gcd(ll a,ll b) 
{ 
    if (b==0) 
        return a; 
    return gcd(b,a%b);      
} 

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

bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}  

struct test
{
public:
    ll x,y,z;
};

bool compare(const test &aa,const test &bb)
{
    return aa.x<bb.x;
}

ll inv(ll a)
{
    ll p=mod;
    ll b=p-2,ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}

ll a_pow_b(ll a,ll b)
{
    ll p=mod;
    ll ans=1;
    for(;b > 0;a = a * a % p,b >>= 1)if(b & 1)ans = ans * a % p;
    return ans;
}

ll ncr(ll n,ll m)
{
    ll p=mod;
    if(m > n)return 0;
    ll up=1,down=1;
    for(int i=n-m+1;i<n+1;i++)up*=i,up%=p;
    for(int i=1;i<m+1;i++)down*=i,down%=p;
    return up*inv(down)%p;
}

bool isPerfectSquare(ll x) 
{   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 

bool inc(ll arr[], ll n) 
{ 
    // Array has one or no element 
    if (n == 0 || n == 1) 
        return true; 
  
    for (ll i = 1; i < n; i++) 
  
        // Unsorted pair found 
        if (arr[i - 1] > arr[i]) 
            return false; 
  
    // No unsorted pair found 
    return true; 
} 

ll countDigit(ll n) 
{ 
    return floor(log10(n) + 1); 
} 

ll nth_fibo(ll n) 
{ 
  double phi = (1 + sqrt(5)) / 2; 
  return round(pow(phi, n) / sqrt(5)); 
} 
string inttostr(ll no)
{
    ll num=no;
    ostringstream str1; 
    str1 << num; 
    string geek = str1.str();
    return geek;
}
ld calcangle(ld h,ld m,string value)
{
    long double deg=fabs((60*h-11*m)/2); 
    if(value=="degree")
    {
        return deg;
    }
    else
    {
        long double cosdeg=cos(deg*PI/180);
        return cosdeg;
    }
}
// vector<ll> spf(1000005,0);
// ll maxn=1e5+5;
// map<ll,set<ll>> divi;
// void seive1(){
//     for(ll i=1;i<maxn;i++){
//         spf[i] = i;
//     }
//     spf[2] = 2;
//     for(ll i=4;i<maxn;i+=2){
//         spf[i]=2;
//     }
//     for(ll i=3;i<maxn;i+=2){
//         if(spf[i]==i){
//             for(ll j=i*i;j<maxn;j+=i){
//                 if(spf[j]==j)
//                     spf[j] = i;
//             }
//         }
//     }
// }

// void calcdiv(ll x)
// {
//     ll n = x;
//     while(x!=1)
//     {
//         divi[n].insert(spf[x]);
//         x/=spf[x];
//     }
// }
// map<ll,set<ll>> divi;
// void divisors(ll n)
// {
//     for(ll i=1;i<=n;i++)
//     {
//         //divi[i].insert(1);
//         for(ll j=i;j<=n;j+=i)
//         {
//             divi[j].insert(i);
//         }
//     }
// }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
////////////////////////////////////////              CODE                   ///////////////////////////////////////////////////////////////
////////////////////////////////////////                                     ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
void AcDegaYe()
{
    long double a, b, h, m;
    cin>>a>>b>>h>>m;
    ld cosdeg=calcangle(h,m,"radian");
    long double c =sqrt(a*a+b*b-2*a*b*cosdeg);
    cout<<setprecision(20)<<c<<endl;
}
int main()
{   
    
    fastio
    //ll t;
    //cin>>t;
    ll t=1;
    while(t--)
    {
        AcDegaYe();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 4200