Count the number of occurrences of x from the current row to the first row.