#B3701. Lightning Rods

    ID: 11360 Type: Default 1000ms 256MiB

Lightning Rods

Lightning Rods

There are ( n ) lightning rods arranged in a row and numbered from ( 1 ) to ( n ). In addition, there are ( m ) lightning strikes. The ( i)-th lightning strike hits the rods at positions ( a_i - 2 ) (if it exists), ( a_i - 1 ) (if it exists), ( a_i ), ( a_i + 1 ) (if it exists), and ( a_i + 2 ) (if it exists). After all ( m ) strikes, determine the number of rods that have been hit at least once.

Note: All positions must be within the range ( [1, n] ).

inputFormat

The input consists of two lines. The first line contains two integers ( n ) and ( m ) separated by a space, where ( n ) is the number of lightning rods and ( m ) is the number of lightning strikes. The second line contains ( m ) integers ( a_1, a_2, \dots, a_m ), representing the positions of the rods where the lightning strikes are centered.

outputFormat

Output a single integer which is the number of lightning rods that are hit by at least one lightning strike.

sample

10 3
3 6 7
9