Demo: count number of times A is in same position as B
Put this in A's "On Update" script:
If(flag && A==B,SetValue(count, count+1))
SetValue(flag, A!=B)
If(flag && A==B,SetValue(count, count+1))
SetValue(flag, A!=B)