Secret ">" Stacking Challenge: grading
Husk, 18 bytes
Lδ↑€…¢ŀT¹↑εΨ↑-↔m¥0

Try it online!
Takes a 0-1 matrix.
Explanation
There are three occurrences of ↑ in this program, and they all work differently thanks to the modifier functions δ and Ψ.
By default, ↑α expects α to be a unary function, takes a list and returns the longest prefix of elements for which α returns a truthy value.
Ψ↑α expects α to be binary, and returns the longest prefix of elements x for which α x y is truthy, where y is the next element.
δ↑α expects α to be binary and takes two lists instead of one.
It returns the longest prefix of the second list whose elements y satisfy α x y, where x is the corresponding element of the first list.
Input is a list of lists of integers.
Example: [[0,1,1],[1,0,1],[1,1,0],[1,0,1],[1,1,0],[0,0,1],[0,1,1]]

m     Map
 ¥0   indices where 0 occurs:
        [[1],[1,2],[3],[2],[3],[2],[1]]
↔     Reverse:
        [[1],[2],[3],[2],[3],[1,2],[1]]

 ↑    Take while
Ψ     this element and the next
  -   have nonempty set difference:
        [[1],[2],[3],[2],[3],[1,2]]

↑     Take while
 ε    this element is a singleton:
        [[1],[2],[3],[2],[3]]
      Call this list X.

ŀT¹   Indices of input transposed:
        [1,2,3]
¢     Cycle infinitely:
        [1,2,3,1,2,3,..]
…     Rangify:
        [1,2,3,2,1,2,3,2,1,..]
 ↑    Take from X while
δ     the corresponding integer in this list
  €   is an element of it:
        [[1],[2],[3],[2]]
L     Length: 4