import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    real a, b, h, m;
    scan(a, b, h, m);
    // writeln(PI);
    double h_angle = ((60 * h + m) / 720) * 2 * PI;
    // writeln(h_angle);
    //12時間=720分で360°
    double m_angle = (m / 60) * 2 * PI;
    // writeln(m_angle);
    //60分で360°
    double angle = h_angle - m_angle;
    // writeln(angle);
    double ans = a ^^ 2 + b ^^ 2 - (2 * a * b * cos(angle));
    writef("%.10f", sqrt(ans));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
