PZZAPGON - Pizza and pigeons

You're delivering a lot of pizzas in a large city, laid out on a grid, and you have the instructions to get from each address to the next address in the following format:
2N 4W
3S 2E
Assuming you start at 0,0 the above instructions would take you to 1S 2E (or -1,2 assuming negative values for W and S).
At the end of your journey you have to send a message home by pigeon.

How far does the pigeon have to fly?  Round up to the nearest integer.

Input

The first line of the input is the number of pizzas to deliver, N. N<100.

The N subsequent lines contain directions from the previous pizza's location to the current pizza's location.

Output

A single number representing the distance that a pigeon would have to fly, to return to the pizza shop (the start of the mission). Round up to the nearest integer.

Example

Input:
3
4W 4N
3E 5S
2W 4N Output: 5

Added by:handee
Date:2020-06-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.