v = {} n = 6 c = 0 for i = 1, n do z = {} for j = 1, 5 do table.insert(z, io.read("*n")) end v[i] = z end for i = 1, n do ci = 0 for j = 1, 4 do if math.abs(v[i][j] - v[i][j+1]) > 3 then ci = 1 end end sort1 = v[i] table.sort(sort1) sort2 = v[i] table.sort(sort2, function(a,b) return a > b end) x = 0 y = 0 for j = 1,5 do if v[i][j] ~= sort1[j] then x = 1 end if v[i][j] ~= sort2[j] then y = 1 end end if x == 1 or y == 1 then c1 = 1 end if ci == 0 then c = c + 1 end end print(c)