N,K = map(int,raw_input().split()) M = [[0]*1001 for i in xrange(1001)] for loop in xrange(N): x,y,hp = map(int,raw_input().split()) x += 500; y += 500 M[y][x] = hp A = [[0]*1002 for i in xrange(1002)] for loop in xrange(K): ax,ay,w,h,d = map(int,raw_input().split()) ax += 500; ay += 500 for y in xrange(ay,ay+h+1): A[y][ax] += d A[y][ax+w+2] -= d ans = 0 for y in xrange(1001): for x in xrange(1,1001): A[y][x] += A[y][x-1] if M[y][x] > A[y][x]: ans += 1 print ans