#include <bits/stdc++.h>
using namespace std;

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

#define eps 1e-12
#define PI acos(-1)

using ll = long long;
using ld = long double;

////////////////////////////////// Must Have's //////////////////////////////////

template<typename p_type>
struct Point {
    p_type x, y;
    Point(p_type _x = 0, p_type _y = 0) : x(_x), y(_y) {}
    
    bool operator ==(Point rhs) const { return fabs(x - rhs.x) < eps && fabs(y - rhs.y) < eps; }
    bool operator <(Point rhs) const { return tie(x, y) < tie(rhs.x, rhs.y); }
    Point operator +(Point rhs) const { return Point(x + rhs.x, y + rhs.y); }
    Point operator -(Point rhs) const { return Point(x - rhs.x, y - rhs.y); }
};

template<typename p_type>
ostream& operator <<(ostream& out, Point<p_type> p) {
    return out << fixed << setprecision(3) << "(" << p.x << ", " << p.y << ")";
}

template<typename p_type>
istream& operator >>(istream& in, Point<p_type>& p) {
    return in >> p.x >> p.y;
}

template<typename v_type>
struct Vec {
    v_type x, y;
    
    Vec(v_type _x = 0, v_type _y = 0) : x(_x), y(_y) {}
    Vec(Point<v_type> a, Point<v_type> b) {
        x = b.x - a.x;
        y = b.y - a.y;
    }
    
    Vec operator +(Vec rhs) const { return Vec(x + rhs.x, y + rhs.y); }
    Vec operator -(Vec rhs) const { return Vec(x - rhs.x, y - rhs.y); }
    
    Vec& scale(v_type s) { return *this = Vec(x * s, y * s); }
    Vec& rot(ld theta) {
        v_type new_x = x * cos(theta) - y * sin(theta);
        v_type new_y = x * sin(theta) + y * cos(theta);
        return *this = Vec(new_x, new_y);
    }
    
    v_type dot(Vec rhs) const { return x * rhs.x + y * rhs.y; }
    v_type cross(Vec rhs) const { return x * rhs.y - y * rhs.x; }
    ld mag() const { return sqrt(x*x + y*y); }
};

using P = Point<ld>;
using V = Vec<ld>;

bool angleCmp(P a, P b) {
    V va(a.x, a.y), vb(b.x, b.y);
    if(va.cross(vb) == 0) {
        return va.mag() < vb.mag();
    } else {
        return atan2(va.y, va.x) < atan2(vb.y, vb.x);
    }
}

ld dist(P a, P b) {
    return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}

ld angle(V u, V v) {
    return acos(u.dot(v) / (u.mag() * v.mag()));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    ld theta = ld(m) / 60;
    theta *= 2*PI;
    V minute(P(0,0),P(0,b));
    minute.rot(2*PI-theta);
    theta = ld(h) / 12 + ld(m) / 60 / 12;
    theta *= 2*PI;
    V hour(P(0,0),P(0,a));
    hour.rot(2*PI-theta);
    P x(minute.x,minute.y), y(hour.x,hour.y);
    debug() nav(x) nav(y);
    cout << dist(x, y) << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 4148