#![allow(unused_imports, unused_macros)]

use kyoproio::*;
use std::{
    collections::*,
    io::{self, prelude::*},
    iter,
    mem::{replace, swap},
};

fn main() -> io::Result<()> {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024)
        .spawn(solve)?
        .join()
        .unwrap();
    Ok(())
}

fn solve() {
    let stdin = io::stdin();
    let mut kin = KInput::new(stdin.lock());
    let stdout = io::stdout();
    let mut out = io::BufWriter::new(stdout.lock());
    macro_rules! output { ($($args:expr),+) => { write!(&mut out, $($args),+).unwrap(); }; }
    macro_rules! outputln {
        ($($args:expr),+) => { output!($($args),+); outputln!(); };
        () => { output!("\n"); if cfg!(debug_assertions) { out.flush().unwrap(); } }
    }

    let pi = std::f64::consts::PI;
    let (a, b, h, m): (f64, f64, f64, f64) = kin.input();
    let hz = Complex::polar(a, (h + m / 60.) / 12. * 2. * pi);
    let mz = Complex::polar(b, m / 60. * 2. * pi);
    let ans = (hz - mz).abs();
    outputln!("{}", ans);
}

#[derive(Clone, Copy, Default, PartialEq, Debug)]
pub struct Complex(pub f64, pub f64);
impl Complex {
    pub fn polar(r: f64, theta: f64) -> Self {
        Self(r * theta.cos(), r * theta.sin())
    }
    pub fn conj(self) -> Self {
        Self(self.1, self.0)
    }
    pub fn inv(self) -> Self {
        let d = self.norm();
        Self(self.0 / d, -self.1 / d)
    }
    pub fn norm(self) -> f64 {
        self.0.powi(2) + self.1.powi(2)
    }
    pub fn abs(self) -> f64 {
        self.0.hypot(self.1)
    }
    pub fn arg(self) -> f64 {
        self.1.atan2(self.0)
    }
    pub fn exp(self) -> Self {
        let (s, c) = self.1.sin_cos();
        Self(c, s).scale(self.0.exp())
    }
    pub fn powf(self, s: f64) -> Self {
        Self::polar(self.abs().powf(s), s * self.arg())
    }
    pub fn normalize(self) -> Self {
        self.scale(1. / self.abs())
    }
    pub fn scale(self, s: f64) -> Self {
        Self(s * self.0, s * self.1)
    }
    pub fn dot(self, other: Self) -> f64 {
        (self * other).0
    }
    pub fn cross(self, other: Self) -> f64 {
        (self.conj() * other).1
    }
    pub fn project_onto(self, onto: Self) -> Self {
        onto.scale(self.dot(onto) / self.norm())
    }
    pub fn reflect(self, normal: Self) -> Self {
        self.project_onto(normal).scale(2.) - self
    }
}
use std::ops::*;
impl Neg for Complex {
    type Output = Self;
    fn neg(self) -> Self {
        Self(-self.0, -self.1)
    }
}
impl Add for Complex {
    type Output = Self;
    fn add(self, other: Self) -> Self {
        Self(self.0 + other.0, self.1 + other.1)
    }
}
impl AddAssign for Complex {
    fn add_assign(&mut self, other: Self) {
        self.0 += other.0;
        self.1 += other.1;
    }
}
impl Sub for Complex {
    type Output = Self;
    fn sub(self, other: Self) -> Self {
        Self(self.0 - other.0, self.1 - other.1)
    }
}
impl SubAssign for Complex {
    fn sub_assign(&mut self, other: Self) {
        self.0 -= other.0;
        self.1 -= other.1;
    }
}
impl Mul for Complex {
    type Output = Self;
    fn mul(self, other: Self) -> Self {
        let Self(re1, im1) = self;
        let Self(re2, im2) = other;
        Self(re1 * re2 - im1 * im2, im1 * re2 + re1 * im2)
    }
}
impl MulAssign for Complex {
    fn mul_assign(&mut self, other: Self) {
        *self = *self * other;
    }
}
impl Div for Complex {
    type Output = Self;
    fn div(self, other: Self) -> Self {
        let Self(re1, im1) = self;
        let Self(re2, im2) = other;
        Self(re1 * re2 + im1 * im2, im1 * re2 - re1 * im2).scale(other.norm())
    }
}
impl DivAssign for Complex {
    fn div_assign(&mut self, other: Self) {
        *self = *self / other;
    }
}
impl From<f64> for Complex {
    fn from(x: f64) -> Self {
        Self(x, 0.)
    }
}

// -----------------------------------------------------------------------------
pub mod kyoproio {
    use std::io::prelude::*;
    pub trait Input {
        fn str(&mut self) -> &str;
        fn input<T: InputParse>(&mut self) -> T {
            T::input(self)
        }
        fn iter<T: InputParse>(&mut self) -> Iter<T, Self> {
            Iter(self, std::marker::PhantomData)
        }
        fn seq<T: InputParse, B: std::iter::FromIterator<T>>(&mut self, n: usize) -> B {
            self.iter().take(n).collect()
        }
    }
    pub struct KInput<R> {
        src: R,
        buf: String,
        pos: usize,
    }
    impl<R: BufRead> KInput<R> {
        pub fn new(src: R) -> Self {
            Self {
                src,
                buf: String::with_capacity(1024),
                pos: 0,
            }
        }
        pub fn src(&mut self) -> &mut R {
            &mut self.src
        }
    }
    impl<R: BufRead> Input for KInput<R> {
        fn str(&mut self) -> &str {
            loop {
                if self.pos >= self.buf.len() {
                    self.pos = 0;
                    self.buf.clear();
                    if self.src.read_line(&mut self.buf).expect("io error") == 0 {
                        return &self.buf;
                    }
                }
                let range = self.pos
                    ..self.buf[self.pos..]
                        .find(|c: char| c.is_ascii_whitespace())
                        .map(|i| i + self.pos)
                        .unwrap_or_else(|| self.buf.len());
                self.pos = range.end + 1;
                if range.end > range.start {
                    return &self.buf[range];
                }
            }
        }
    }
    pub struct Iter<'a, T, I: ?Sized>(&'a mut I, std::marker::PhantomData<*const T>);
    impl<'a, T: InputParse, I: Input + ?Sized> Iterator for Iter<'a, T, I> {
        type Item = T;
        fn next(&mut self) -> Option<T> {
            Some(self.0.input())
        }
    }
    pub trait InputParse: Sized {
        fn input<I: Input + ?Sized>(src: &mut I) -> Self;
    }
    impl InputParse for Vec<u8> {
        fn input<I: Input + ?Sized>(src: &mut I) -> Self {
            src.str().as_bytes().to_owned()
        }
    }
    macro_rules! from_str_impl {
        { $($T:ty)* } => {
            $(impl InputParse for $T {
                fn input<I: Input + ?Sized>(src: &mut I) -> Self {
                    src.str().parse::<$T>().expect("parse error")
                }
            })*
        }
    }
    from_str_impl! {
        String char bool f32 f64 isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128
    }
    macro_rules! tuple_impl {
        ($H:ident $($T:ident)*) => {
            impl<$H: InputParse, $($T: InputParse),*> InputParse for ($H, $($T),*) {
                fn input<I: Input + ?Sized>(src: &mut I) -> Self {
                    ($H::input(src), $($T::input(src)),*)
                }
            }
            tuple_impl!($($T)*);
        };
        () => {}
    }
    tuple_impl!(A B C D E F G);
    #[macro_export]
    macro_rules! kdbg {
        ($($v:expr),*) => {
            if cfg!(debug_assertions) {
                dbg!($($v),*)
            } else {
                ($($v),*)
            }
        }
    }
}


Measured memory_bytes: 3076