import std;

alias P = Tuple!(double, "x", double, "y");

double radians(double deg) {
    return PI * deg / 180.0;
}

P rotate(P p, double degree) {
    auto rad = radians(degree);
    auto x = p.x * cos(rad) - p.y * sin(rad);
    auto y = p.x * sin(rad) + p.y * cos(rad);
    return P(x, y);
}

double calc(double a, double b, double h, double m) {
    // 短針:
    //     1 周するのに 12 * 60 分
    //     現在の角度 = (60 * h + m) / (12 * 60) * 360
    // 長針:
    //     1 周するのに 60 分
    //     現在の角度 = m / 60 * 360

    auto s = rotate(P(0, a), (60 * h + m) / (12 * 60) * 360);
    auto t = rotate(P(0, b), m / 60 * 360);
    return hypot(s.x - t.x, s.y - t.y);
}

// 複素数を用いた解法
double calc2(double a, double b, double h, double m) {
    auto s = fromPolar(a, (60 * h + m) / (12 * 60) * 2 * PI);
    auto t = fromPolar(b, m / 60 * 2 * PI);
    return abs(s - t);
}

// Vec2 を用いた解法
double calc3(double a, double b, double h, double m) {
    auto s = Vec2(0, a).rotate((60 * h + m) / (12 * 60) * 2 * PI);
    auto t = Vec2(0, b).rotate(m / 60 * 2 * PI);
    return Vec2.distance(s, t);
}

void main() {
    int a, b, h, m; scan(a, b, h, m);
    writefln("%.20f", calc3(a, b, h, m));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

struct Vec2 {
    immutable double x;
    immutable double y;

    this(double x, double y) {
        this.x = x;
        this.y = y;
    }

    double dot(Vec2 other) { return this.x * other.x + this.y * other.y; }
    double cross(Vec2 other) { return this.x * other.y - other.x * this.y; }
    double mag() { return sqrt(magSq()); }
    double magSq() { return this.x * this.x + this.y * this.y; }

    Vec2 normalized() {
        auto m = mag();
        if (m != 0 && m != 1)
            return Vec2(this.x / m, this.y / m);
        return this;
    }

    Vec2 rotate(double rad) const {
        auto x2 = this.x * cos(rad) - this.y * sin(rad);
        auto y2 = this.x * sin(rad) + this.y * cos(rad);
        return Vec2(x2, y2);
    }

    static double distance(Vec2 a, Vec2 b) {
        return (a - b).mag();
    }

    // a の b への射影を求める
    static Vec2 project(Vec2 a, Vec2 b) {
        auto e = b.normalized();
        return a.dot(e) * e;
    }

    Vec2 opUnary(string op)() if (op == "-") { return Vec2(-this.x, -this.y); }
    Vec2 opBinary(string op)(Vec2 o) if (op == "+") { return Vec2(this.x + o.x, this.y + o.y); }
    Vec2 opBinary(string op)(Vec2 o) if (op == "-") { return Vec2(this.x - o.x, this.y - o.y); }
    Vec2 opBinary(string op)(double d) if (op == "*") { return Vec2(this.x * d, this.y * d); }
    Vec2 opBinaryRight(string op)(double d) if (op == "*") { return Vec2(this.x * d, this.y * d); }
}
