Counting the Endpoints of an ASCII Art You should write a program or function which receives a string representing an ASCII art as input and outputs or returns the number of endpoints in the input.

The input will consist of the characters space - | + (with 0, 2, 2 and 4 endpoints respectively) and linebreaks. E.g.:

-|++-
  +


Two adjacent characters are connected and hence lose 1 endpoint each in the following cases:

--  -+  +- |  |  +  +  ++
           |  +  |  +


The first example has

2+2+2+2+1+
    3        = 12


endpoints.

Input


Input will be a string consisting of the characters space, -, |, + and newline.
Input length can be 0 length and any input matching the above description is valid (in regex input is [ -+|\n]*).
Trailing newline is optional.


Output


A single non-negative integer, the number of endpoints.


Examples

Outputs are after the last row of their inputs.

+
4 

-|++-
  +
12 

+--+
|  |
+--+
8 

  |  |
  +--+-- |||
12 

--++
 |||--
10 

&lt;empty input&gt;
0 


|
|     
2 

--
++--
 ++
   --+
  +++ || 

 ----
30 


This is code golf so the shortest entry wins.
Snails, 29
A
\+|\-)lr!\-|(\+|\|)n!\|}!\+

I added line comments with ,,, in order to make a commented version.
A                    ,, Count all accepting paths
        \+ | \- )    ,, Literal '+' or '-'        
        lr           ,, Set direction to left or right
        !\-          ,, Assert next char is not '-'
    |                ,, Or...
        ( \+ | \| )  ,, Literal '+' or '|'
        n            ,, Turn 90 degrees right or left (from initial direction right)
        !\|          ,, Assert next char is not '|'
}                    ,, Group everything previous
!\+                  ,, Assert next char is not '+'