import math

class Watch():
    """
    This is a class to calculate angle and distance between two hands.
    
    Attributes:
        length_of_hour_hand(int): Length of the hour hand.
        length_of_minute_hand(int): Length of the minute hand.
        hours(int): Hours.
        minutes(int): Minutes.
    """

    def __init__(self, length_of_hour_hand, length_of_minute_hand,
                 hours, minutes):
        """
        The constructor for Watch class.

        Attributes:
            length_of_hour_hand(int): Length of the hour hand.
            length_of_minute_hand(int): Length of the minute hand.
            hours(int): Hours.
            minutes(int): Minutes.
            angle_between_two_hands(float): 
                Angle between the hour hand and the minute one.
            distance_between_two_hands(float): 
                Distance between the tip of hour hand and 
                that of minute one.
        """
        self.length_of_hour_hand = length_of_hour_hand
        self.length_of_minute_hand = length_of_minute_hand
        self.hours = hours
        self.minutes = minutes
        self.angle_between_two_hands = None
        self.distance_between_two_hands = None

    def calculate_angle_between_two_hands(self):
        """
        Calculate angle between the hour hand and the minute one.
        """

        #degrees_of_hour_hand: float, radian
        degrees_of_hour_hand = (((self.hours + self.minutes/60.)/12.)
                               *2.*math.pi)
        #degrees_of_minute_hand: float, radian
        degrees_of_minute_hand = (self.minutes/60.)*2.*math.pi
        
        #angle_between_two_hands: float, radian
        angle_between_two_hands = (degrees_of_hour_hand
                                   - degrees_of_minute_hand)
        
        self.angle_between_two_hands = angle_between_two_hands
    
    def calculate_distance_between_two_hands(self):
        """
        Calculate distance between the tip of hour hand and 
        that of minute hand.
        """                          

        self.distance_between_two_hands = math.sqrt(
            self.length_of_hour_hand**2 + self.length_of_minute_hand**2
            - 2*self.length_of_hour_hand*self.length_of_minute_hand
            *math.cos(self.angle_between_two_hands))

#A, B, H, M: ints, A: the length of the hour hand, 
#B: the length of the minute hand, H: hours, M: minutes
A, B, H, M = [int(s) for s in input().split(" ")] 

watch = Watch(A, B, H, M)
watch.calculate_angle_between_two_hands()
watch.calculate_distance_between_two_hands()
print(watch.distance_between_two_hands

### FIXED CODE ###

import math

class Watch():
    """
    This is a class to calculate angle and distance between two hands.
    
    Attributes:
        length_of_hour_hand(int): Length of the hour hand.
        length_of_minute_hand(int): Length of the minute hand.
        hours(int): Hours.
        minutes(int): Minutes.
    """

    def __init__(self, length_of_hour_hand, length_of_minute_hand,
                 hours, minutes):
        """
        The constructor for Watch class.

        Attributes:
            length_of_hour_hand(int): Length of the hour hand.
            length_of_minute_hand(int): Length of the minute hand.
            hours(int): Hours.
            minutes(int): Minutes.
            angle_between_two_hands(float): 
                Angle between the hour hand and the minute one.
            distance_between_two_hands(float): 
                Distance between the tip of hour hand and 
                that of minute one.
        """
        self.length_of_hour_hand = length_of_hour_hand
        self.length_of_minute_hand = length_of_minute_hand
        self.hours = hours
        self.minutes = minutes
        self.angle_between_two_hands = None
        self.distance_between_two_hands = None

    def calculate_angle_between_two_hands(self):
        """
        Calculate angle between the hour hand and the minute one.
        """

        #degrees_of_hour_hand: float, radian
        degrees_of_hour_hand = (((self.hours + self.minutes/60.)/12.)
                               *2.*math.pi)
        #degrees_of_minute_hand: float, radian
        degrees_of_minute_hand = (self.minutes/60.)*2.*math.pi
        
        #angle_between_two_hands: float, radian
        angle_between_two_hands = (degrees_of_hour_hand
                                   - degrees_of_minute_hand)
        
        self.angle_between_two_hands = angle_between_two_hands
    
    def calculate_distance_between_two_hands(self):
        """
        Calculate distance between the tip of hour hand and 
        that of minute hand.
        """                          

        self.distance_between_two_hands = math.sqrt(
            self.length_of_hour_hand**2 + self.length_of_minute_hand**2
            - 2*self.length_of_hour_hand*self.length_of_minute_hand
            *math.cos(self.angle_between_two_hands))

#A, B, H, M: ints, A: the length of the hour hand, 
#B: the length of the minute hand, H: hours, M: minutes
A, B, H, M = [int(s) for s in input().split(" ")] 

watch = Watch(A, B, H, M)
watch.calculate_angle_between_two_hands()
watch.calculate_distance_between_two_hands()
print(watch.distance_between_two_hands)