#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;
 
tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderset;
 
const int N=2e5+5;
 
 
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    double x,y,a,b;
    cin>>x>>y>>a>>b;
    double de=(a*30+b/2)-b*6;
    if(de<0) de=-de;
    if(de>=180) de=360-de;
    double torad=de*0.01745329252;
    double val=cos(torad);
    cout<<fixed<<setprecision(9)<<sqrt(x*x+y*y-2*x*y*val);
}