def calculate_dinner_time():
    try:
        with open("dinner.in", "r", encoding="utf-8") as input_file:
            n, a = map(int, input_file.readline().strip().split())
            
            total_b = 0  
            total_c = 0
            for _ in range(n):
                b, c = map(int, input_file.readline().strip().split())
                total_b += b
                total_c += c
        cook_total = total_b + total_c
        result = max(cook_total, a)
        with open("dinner.out", "w", encoding="utf-8") as output_file:
            output_file.write(str(result))
        
        print(f"计算完成！总耗时为：{result}")
    except FileNotFoundError:
        print("错误：未找到dinner.in文件，请确保该文件与代码在同一目录下！")
    except ValueError:
        print("错误：输入文件格式错误！请检查第一行是两个正整数，后续每行是两个正整数。")
    except Exception as e:
        print(f"运行出错：{str(e)}")

if __name__ == "__main__":
    calculate_dinner_time()