Count value between | sign

Hi
I have a file inw which values are seperated by "|"
I want to count number of values present in each line of the file
Input file

AS|23 34|BD|A2|890
AK|23 44|D|A2|89076|89
AF|23 34|BD|A2|8  

Result

5  
6
5

there are 5 values inside | sign hence o/p will be 5 similarly in 2nd line it will be 6 and so on
Pls help me

awk -F'|'   '{print NF}' inputfile
 $ ruby -ne 'puts $_.count("|")+1' file