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

using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
// #define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 

// float cal_cos(float n) 
// { 
//     std::cout << std::fixed;
// std::cout << std::setprecision(9);
//     float accuracy = 0.000000001, x1, denominator, cosx, cosval; 
  
//     // Converting degrees to radian 
//     n = n * (3.142 / 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; 
// }
signed main(){
    std::cout << std::fixed;
std::cout << std::setprecision(20);
    int t=1;
    // cin>>t;
    while(t--){
        int a,b,h,m;
        cin>>a>>b>>h>>m;
        // float x = (1.0*m)/2;
        // int m1=(int)m;
        // int z=(int)m1/5;
        // float y=1.0*z*30;
        // z = (int)m1%5;
        // y+=(6*z);
        // float x1=h*30;
        // x1+=x;
        // // cout<<y<<" "<<x1<<endl;
        // y=abs(x1-y);
        // if(y>180)
        // y=360-y;



        double hour_angle = 0.5 * (h * 60 + m);  
        double minute_angle = 6.0 * m;  
  
    // Find the difference between two angles  
        double angle = abs(hour_angle - minute_angle);  
  
    // Return the smaller angle of two possible angles  
        angle = min(360 - angle, angle); 

        // cout<<angle<<endl;

        // cout<<y<<endl;
        
        double rad= (3.14159265358979323846)/180;
        rad*=angle;
        // cout<<rad<<endl;
        double val = cos(rad);
        // val = val/(10000000000);
        // cout<<val<<endl;
        double ans = (a*a)+(b*b);
        // cout<<ans<<endl;
        // cout<<2*a*b*val<<endl;
        // if((int)val!=0)
        // cout<<(val)*(2*a*b)<<endl;
        ans-=(2*a*b*val);
        // cout<<ans<<endl;
        ans = sqrt(ans);
        cout<<ans<<endl;
        
        

    }
    return 0;
}

Measured memory_bytes: 4220