#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>
#include <cstdint>
#include <string>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define M_PI 3.14159265358979323846

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
pair <int, int> vu[8] = { {0,1}, {1,0} , {1,-1},{0,-1},{-1,0},{-1,1},{0,1}, {1,0} }; // EWSN

const int max_v = 1e4 + 7;
const int INF = 1e8 + 7;

typedef long double val;

struct  point
{
	double x;
	double y;
};

struct vec
{
	point s; 
	point e;
	point component; // 성분
};

inline point findV(point a, point b) { return { b.x - a.x ,b.y - a.y }; } // v(a,b)
inline val ptp(point a, point b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); } // 점 점 거리

int cross(point v, point u) // 벡터 외적
{
	val temp = v.x * u.y - u.x * v.y;
	if (temp > 0) return 1; // 반시계
	else if (temp == 0) return 0; // 평행
	else return -1; // 시계
}

int dotproduct(point v, point u) // 벡터 내적
{
	val ck = (v.x * u.x + v.y * u.y);
	if (ck > 0) return 1; // 벡터 정방향
	else if (ck == 0) return 0; // 벡터 수직
	else return -1; // 벡터 역방향
}

int overlap(vec u, vec v) // INF : 교점 무한히 많음 , 0 -> 교점 0개 , 1개 -> 점 끝에서 만난 경우, 2개 교점 1개
{
	int w1 = cross(u.component, findV(u.s, v.s));
	int w2 = cross(u.component, findV(u.s, v.e));
	if (w1 != w2)
	{

		if (w1 == 0)
		{
			if ((v.s.x == u.s.x && v.s.y == u.s.y) || (v.s.x == u.e.x && v.s.y == u.e.y)) return 1;
		}
		else if (w2 == 0)
		{
			if ((v.e.x == u.s.x && v.e.y == u.s.y) || (v.e.x == u.e.x && v.e.y == u.e.y)) return 1;
		}

		w1 = cross(v.component, findV(v.s, u.s));
		w2 = cross(v.component, findV(v.s, u.e));
		if (w1 != w2)
		{
			if (w1 == 0 || w2 == 0) return 1;

			return 2;
		}
	}
	else if (w1 == 0 && w2 == 0)
	{
		w1 = dotproduct(u.component, findV(u.s, v.s));
		w2 = dotproduct(u.component, findV(u.e, v.s));


		if (w1 == 0)
		{
			if (dotproduct(u.component, findV(u.s, v.e)) < 0) return 1;
			else return	INF;
		}
		if (w2 == 0)
		{
			if (dotproduct(u.component, findV(u.e, v.e)) > 0) return 1;
			else return INF;
		}


		if (w1 != w2) return INF;
		else
		{
			w1 = dotproduct(u.component, findV(u.s, v.e));
			w2 = dotproduct(u.component, findV(u.e, v.e));

			if (w1 == 0)
			{
				if (dotproduct(u.component, findV(u.s, v.s)) < 0) return 1;
				else return INF;
			}
			if (w2 == 0)
			{
				if (dotproduct(u.component, findV(u.e, v.s)) > 0) return 1;
				else return INF;
			}

			if (w1 != w2) return INF;
			else
			{
				if (dotproduct(u.component, findV(u.s, v.s)) == dotproduct(u.component, findV(u.s, v.e))) return 0;
				else return INF;
			}

		}
	}
	return 0;
}

int main()
{
	//ios_base::sync_with_stdio(0); cin.tie(0);
	
	long double hl, ml;
	long double h, m;
	long double deg = (acos(-1.0))/180;
	ci(hl >> ml >> h >> m);
	
	h *= 30;	
	h += 30 * (m / 60);
	m *= 6;
	
	
	h *= deg;
	m *= deg;
	
	point a, b;
	a.x = cos(h) * hl;
	a.y = sin(h) * hl;
	b.x = cos(m) * ml;
	b.y = sin(m) * ml;
	
	printf("%.12lf", hypot(a.x-b.x,a.y-b.y));

	return 0;
}

Measured memory_bytes: 4156