Perl, 87 85 characters
A function that returns 0, 1 or 2, using a regular expression, of course (the newline's only there to avoid the scrollbar):
sub V{$"='';$x='(1|2)';"@_"=~
/^(...)*$x\2\2|^..$x.\3.\3|$x..\4..\4|$x...\5...\5/?$^N:0}
It can be called as V(@b)
, for example.