// Arup Guha
// 1/28/2026
// Anna and Bob Meeting Question 
// Practice Question for COP 3330 Quiz Review

import java.util.*;

public class coincidence {

	public static void main(String[] args) {
		
		// Get Anna's times.
		Scanner stdin = new Scanner(System.in);
		System.out.println("Anna, when did you arrive and leave?");
		int annaStart = stdin.nextInt();
		int annaLeave = stdin.nextInt();
		
		// Get Bob's times.
		System.out.println("Bob, when did you arrive and leave?");
		int bobStart = stdin.nextInt();
		int bobLeave = stdin.nextInt();
		
		// Catch no intersection.
		if (bobLeave <= annaStart || annaLeave <= bobStart)
			System.out.println("Sorry Anna and Bob were never in the restaurant at the same time.");
			
		// Intersection case.
		else {
			int res = Math.min(annaLeave, bobLeave) - Math.max(annaStart, bobStart);
			System.out.println("You were together for "+res+" minutes.");
		}
	}
}