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

//////////////////////////////   Begin Macros

#define all(x) (x).begin(), (x).end()
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define reprev(i, N) for (int i = (int)(N)-1; i >= 0; i--)
#define rep1(i, N) for (int i = 1; i <= (int)(N); i++)
#define rep1rev(i, N) for (int i = (int)(N); i >= 0; i--)
#define forbe(i, b, e) for (int i = (b); i < (e); i++)
#define forberev(i, b, e) for (int i = (e)-1; i >= (b); i--)
#define forfl(i, f, l) for (int i = (f); i <= (l); i++)
#define forflrev(i, f, l) for (int i = (l); i >= (f); i--)
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

template <typename T>
bool chmax(T &m, const T q)
{
  if (m < q)
  {
    m = q;
    return true;
  }
  else
    return false;
}
template <typename T>
bool chmin(T &m, const T q)
{
  if (m > q)
  {
    m = q;
    return true;
  }
  else
    return false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first + r.first, l.second + r.second}; }
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return {l.first - r.first, l.second - r.second}; }
template <typename T>
pair<T, T> operator*(const pair<T, T> &l, const T &r) { return {l.first * r, l.second * r}; }
template <typename T>
pair<T, T> operator/(const pair<T, T> &l, const T &r) { return {l.first / r, l.second / r}; }
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (auto &v : vec)
    is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
  os << "[";
  for (auto v : vec)
    os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
  os << "deq[";
  for (auto v : vec)
    os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
  os << "(" << pa.first << "," << pa.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
  os << "{";
  for (auto v : mp)
    os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
  os << "{";
  for (auto v : mp)
    os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}

template <typename T>
void reset(vector<T> &v, const T reset_to)
{
  for (auto &x : v)
    x = reset_to;
}
inline int popcount(const unsigned int x) { return __builtin_popcount(x); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

ll nC2(ll n)
{
  return n * (n - 1) / 2;
}

const int intinf = numeric_limits<int>::max();
const ll llinf = numeric_limits<ll>::max();
const pii udlr[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

//////////////////////////////   End Macros

// Geometry.h start--------------------------------------------
// references:
// https://ei1333.github.io/luzhiled/snippets/geometry/template.html
// https://dai1741.github.io/maximum-algo-2012/cpp/geometry/geometries2d.h
#pragma once

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

struct Real
{
  static double eps;
  double value;
  Real(double value = 0.0) : value(value) {}
  inline Real operator+() const { return *this; }
  inline Real operator-() const { return Real(-value); }
  inline Real &operator+=(const Real &rhs)
  {
    value += rhs.value;
    return *this;
  }
  inline Real &operator-=(const Real &rhs)
  {
    value -= rhs.value;
    return *this;
  }
  inline Real &operator*=(const Real &rhs)
  {
    value *= rhs.value;
    return *this;
  }
  inline Real &operator/=(const Real &rhs)
  {
    value /= rhs.value;
    return *this;
  }
};
double Real::eps = 1e-8;
bool operator==(const Real &lhs, const Real &rhs) { return abs(lhs.value - rhs.value) < Real::eps; }
bool operator!=(const Real &lhs, const Real &rhs) { return !(lhs == rhs); }
bool operator<=(const Real &lhs, const Real &rhs) { return lhs.value < rhs.value + Real::eps; }
bool operator>=(const Real &lhs, const Real &rhs) { return lhs.value + Real::eps > rhs.value; }
bool operator>(const Real &lhs, const Real &rhs) { return !(lhs <= rhs); }
bool operator<(const Real &lhs, const Real &rhs) { return !(lhs >= rhs); }
Real operator+(const Real &lhs, const Real &rhs) { return Real(lhs) += rhs; }
Real operator-(const Real &lhs, const Real &rhs) { return Real(lhs) -= rhs; }
Real operator*(const Real &lhs, const Real &rhs) { return Real(lhs) *= rhs; }
Real operator/(const Real &lhs, const Real &rhs) { return Real(lhs) /= rhs; }
istream &operator>>(istream &lhs, Real &rhs) { return lhs >> rhs.value; }
ostream &operator<<(ostream &lhs, const Real &rhs) { return lhs << rhs.value; }
Real radian_to_degree(Real r) { return r * 180.0 / M_PI; }
Real degree_to_radian(Real d) { return d * M_PI / 180.0; }

struct Point : public complex<double>
{
  using complex<double>::complex;
  Point(const complex<double> &c) : complex<double>(c) {}
  Point(complex<double> &&c) : complex<double>(c) {}
  Point(const Real &x = 0.0, const Real &y = 0.0) : Point(x.value, y.value) {}

  inline Real x() const { return real(); };
  inline Real y() const { return imag(); };

  inline Point &operator*=(const Real &rhs) { return *this = complex<double>(*this) *= rhs.value; }
  inline Point &operator/=(const Real &rhs) { return *this = complex<double>(*this) /= rhs.value; }
};
bool operator<(const Point &a, const Point &b)
{
  return a.x() != b.x() ? a.x() < b.x() : a.y() < b.y();
}
Point operator*(const Point &lhs, const Real &rhs) { return Point(lhs) *= rhs; }
Point operator/(const Point &lhs, const Real &rhs) { return Point(lhs) /= rhs; }
istream &operator>>(std::istream &lhs, Point &rhs)
{
  Real x, y;
  lhs >> x >> y;
  rhs = {x, y};
  return lhs;
}

Point rotate(const Real &theta, const Point &p) { return Point(cos(theta.value), sin(theta.value)) * p; }
Real dot(const Point &a, const Point &b) { return (conj(a) * b).real(); }
Real cross(const Point &a, const Point &b) { return (conj(a) * b).imag(); }
Real get_angle(const Point &a, const Point &b, const Point &c)
{
  const Point v(a - b), w(c - b);
  double alpha = atan2(v.y().value, v.x().value), beta = atan2(w.y().value, w.x().value);
  double theta = abs(alpha - beta);
  return min(theta, 2 * M_PI - theta);
}
int ccw(const Point &a, Point b, Point c)
{
  b -= a, c -= a;
  if (cross(b, c) > 0)
    return +1; // "counter clockwise"
  if (cross(b, c) < 0)
    return -1; // "clockwise"
  if (dot(b, c) < 0)
    return +2; // "c--a--b"
  if (norm(b) < norm(c))
    return -2; // "a-b--c" (a--b--c or ab--c)
  return 0;    // "a-c-b"
}

struct Line : public pair<Point, Point>
{
  Point a, b;
  Line(const Point &a, const Point &b) : a(a), b(b) { assert(a != b); } // a--b
  Line(const Real &A, const Real &B, Real const &C)                     // Ax+By=C
  {
    assert(!(A == 0 and B == 0));
    if (A == 0)
    {
      a = Point(0, C / B), b = Point(1, C / B);
    }
    else if (B == 0)
    {
      a = Point(C / A, 0), b = Point(C / A, 1);
    }
    else
    {
      a = Point(0, C / B), b = Point(C / A, 0);
    }
  }
};
ostream &operator<<(std::ostream &lhs, const Line &rhs) { return lhs << rhs.a << " to " << rhs.b; }
bool parallel(const Line &l, const Line &m) { return cross(l.a - l.b, m.a - m.b) == 0.0; }
bool orthogonal(const Line &l, const Line &m) { return dot(l.a - l.b, m.a - m.b) == 0.0; }
Point projection(const Line &l, const Point &p)
{
  Real t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + (l.a - l.b) * t;
}
Point reflection(const Line &l, const Point &p)
{
  return p + (projection(l, p) - p) * 2.0;
}
bool intersect(const Line &l, const Point &p)
{
  return abs(ccw(l.a, l.b, p)) != 1;
}
bool operator==(const Line &lhs, const Line &rhs) { return intersect(lhs, rhs.a) and intersect(lhs, rhs.b); }
bool intersect(const Line &l, const Line &m)
{
  return !parallel(l, m) or (l == m);
}

struct Segment : Line
{
  using Line::Line;
};

bool intersect(const Segment &s, const Point &p)
{
  return ccw(s.a, s.b, p) == 0;
}
bool intersect(const Point &p, const Segment &s) { return intersect(s, p); }

bool intersect(const Line &l, const Segment &s)
{
  return ccw(l.a, l.b, s.a) * ccw(l.a, l.b, s.b) <= 0;
}

bool intersect(const Segment &s, const Line &l)
{
  return intersect(l, s);
}

bool intersect(const Segment &s, const Segment &t)
{
  return intersect((Line)s, t) and intersect(s, (Line)t);
}

Real distance(const Point &p, const Point &q)
{
  return abs(p - q);
}

Real distance(const Line &l, const Point &p)
{
  return distance(p, projection(l, p));
}
Real distance(const Point &p, const Line &l)
{
  return distance(l, p);
}

Real distance(const Line &l, const Line &m)
{
  return intersect(l, m) ? 0 : distance(l, m.a);
}

Real distance(const Segment &s, const Point &p)
{
  Point r = projection(s, p);
  if (intersect(s, r))
    return distance(r, p);
  return min(distance(s.a, p), distance(s.b, p));
}
Real distance(const Point &p, const Segment &s)
{
  return distance(s, p);
}

Real distance(const Segment &s, const Segment &t)
{
  if (intersect(s, t))
    return 0;
  return min({distance(s, t.a), distance(s, t.b), distance(s.a, t), distance(s.b, t)});
}

Real distance(const Line &l, const Segment &s)
{
  if (intersect(l, s))
    return 0;
  return min(distance(l, s.a), distance(l, s.b));
}

struct Circle
{
  Point p;
  Real r;
  Circle(const Point &p, const Real &r) : p(p), r(r) {}
};

// Geometry.h end--------------------------------------------

void solve()
{
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  Point hh(0, A);
  Point mh(0, B);
  Point rhh = rotate(-2 * M_PI * (H % 12 * 60.0 + M) / (12.0 * 60.0), hh);
  Point rmh = rotate(-2 * M_PI * M / 60.0, mh);
  cout << distance(rhh, rmh) << endl;
}

int main()
{
  // srand(time(0));
  cout << fixed << setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 4172