#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;

struct Vec2{
    long double x,y;

    Vec2(long double x = 0, long double y = 0): x(x),y(y) {};
    Vec2 operator+(const Vec2& v) const {return Vec2(x+v.x, y+v.y);}
    Vec2& operator+=(const Vec2& v) {x += v.x; y += v.y; return *this;}
    Vec2 operator-(const Vec2& v) const {return Vec2(x-v.x, y-v.y);}

    long double dot(const Vec2& v) const {return x*v.x + y*v.y;}
    long double cross(const Vec2& v) const {return x*v.y - y*v.x;}
    long double norm2() const {return x*x + y*y;}
    long double norm() const {return sqrt(norm2());}

    int ort() const{
        if(y >= 0) return x > 0 ? 1 : 2;
        else return x > 0 ? 4 : 3;
    }
    long double arg(){
        if(equals(x,0) && equals(y,0)) return -1;
        if(equals(x,0)){
            if(y > 0) return 90.0;
            else return 270.0;
        }else if(equals(y,0)){
            if(x > 0) return 0.0;
            else return 180.0;
        }else{
            long double x1 = abs(x);
            long double y1 = abs(y);
            long double a = atan((long double)y1/x1)/ PI * 180;
            if(0 < y && 0 < x) return a;
            else if(0 < y) return 180-a;
            else if(0 < x) return 360-a;
            else return 180+a;
        }
    }

};

bool cmp_vec2arg(const Vec2& a, const Vec2& b){ // <$B$rDj5A(B
    int ao = a.ort(), bo = b.ort();
    if(ao != bo) return ao < bo;
    else return a.cross(b) > 0;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    double A,B; cin >> A >> B;
    int H,M; cin >> H >> M;
    double ah = H * 30 + 0.5 * M;
    double bh = 6 * M;
    double th = abs(ah-bh);
    if(th > 180) th = 360-th;

    double x = sqrt(A*A + B*B - 2 * A*B*cos(PI*th/180));
    cout << x << endl;

}



Measured memory_bytes: 4176