#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

// random generator function:
//~ bool valid(string& s) {
	//~ int m = (int)s.size()/2;
	//~ for (int i = 0; i < m; i++)
		//~ if(s[i] == ')')
			//~ return false;
	//~ return true;
//~ }
//~ int cnt = 0;
//~ vector <int> findLexSmallest(string s) {
	//~ int n = (int)s.size();
	//~ vector<int> ans;
	//~ while (!valid(s)) {
		//~ for (int i = 0; i < n; i++) {
			//~ if (i+ 1 < n && s[i] == ')' && s[i+1] == '(') {
				//~ char c = s[i];
				//~ s.erase(i,1);
				//~ s += c;
				//~ ans.push_back(i);
				//~ ans.push_back(i);
				//~ ans.push_back(n-1);
				//~ cnt++;
			//~ }
		//~ }
	//~ }
	//~ cout<<s<<endl;
	//~ return ans;
//~ }

//~ string compare(string & s1, string& s2) {
	//~ if (s1.size() == s2.size()) {
		//~ int n = min(s1.size(), s2.size());
		//~ for (int i = 0; i < n; i++) {
			//~ if (s1[i] == s2[i]) continue;
			//~ if (s1[i] < s2[i]) {
				//~ return s2;
			//~ }
			//~ else
				//~ return s1;
		//~ }
	//~ }
	//~ return s1.size() > s2.size() ? s1 : s2;
//~ }

//~ int cnt = 0;
//~ string ans;
//~ vector<int> c;
//~ bool vis[10][5001];
//~ int m;
//~ void solve(int n, string& str, int target) {
	
	//~ if (n >= 0 && vis[n][target])
		//~ return;
	//~ if (n < 0 || target <= 0) {
		
		//~ if(target == 0) {
			//~ sort(str.begin(), str.end());
			//~ cout<<target<<" "<<str<<endl;
			//~ if (cnt == 0) {
				//~ ans = str;
			//~ }
			//~ else {
				//~ ans = compare(ans, str);
			//~ }
		//~ }
		//~ return;
	//~ }	
	//~ for (int k = 0; k < m; k++) {
		//~ str += ((k+1) + '0');
		//~ solve(n-1, str, target - c[k]);
		//~ str.pop_back();
	//~ }
	//~ vis[n][target] = true;
//~ }
//~ string largestNumber(vector<int>& cost, int target) {
  //~ clr(vis,false);
  //~ c = cost;
  //~ int n = (int)cost.size();
  //~ m = n;
  //~ string str = "";
  //~ solve(n, str, target); 
  //~ return ans;
//~ }
  

// Driver code 
double distance(double x, double y, double x1, double y1) {
	return sqrt((x-x1)*(x-x1) + (y-y1)*(y-y1));
}
 
double solve(double a, double b, double h, double m) {
	if (h == 12) h = 0;  
  if (m == 60) m = 0;
	double hour_angle = 0.5 * (h * 60 + m);  
	double h_x = a*cos(hour_angle*PI/180.0);
	double h_y = a*sin(hour_angle*PI/180.0);
	
	double minute_angle = 6 * m; 
	double m_x = b*cos(minute_angle*PI/180.0);
	double m_y = b*sin(minute_angle*PI/180.0);
	double dist = distance(h_x, h_y, m_x, m_y);
	return dist;
}

int main() 
{ 
	double a, b, h, m; cin>> a >> b >> h >> m;
	cout<<setprecision(20)<< solve(a, b, h, m);
  return 0; 
} 



Measured memory_bytes: 4160