ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Неотсортированные > задача:


Поезд

Задачи раздела

• Минимумы на отрезке
• Министерство правды
• Монеты и гнезда
• Монополия
• Муравей
• Мячик
• Огромная паркова
• Площади островов.
• Поезд
• Премьер-министр
• Прогрессия
• Проходной балл
• Ситха джедай против
• Сортировка времени
• Тапшырма 1. Вариант 21
• Тапшырма 1. Вариант 22
• Тапшырма 1. Вариант 23

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 1000/1000/1000/1000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

Problem description

A train leaves the first station with N passengers and visits K stations before it arrives at the last station. In each station some passengers got off the train and some passengers got on the train. Everybody in the train got off at the last station. Make a program that calculates how many passengers got off the train at the last station.

Input

The first line of the input has two integers N and K. Each of the following K lines contains two integers, the first one denotes the number of passengers who got off the train at that station, and the second one denotes the number of passengers got on the train at that station.

Output

The output should hava a single integer that is number of passengers who got off the train at the last station.

Example

stdin stdout
5 20
6 15
5 30
20 12
15 8
6 7

40

Для отправки решений необходимо выполнить вход.

www.contester.ru