N, M, T = [int(i) for i in input().split()]
# 输入order
orders = []
for _ in range(M):
order = [int(i) for i in input().split()]
orders.append(order)
# 创建hash_dict, 优先级priority初始为0
hash_dict = {storeID : 0 for storeID in range(1, N + 1)}
priority_list = [0]*(N + 1)
# 遍历orders,同时维护hash_dict
for t in range(1, T+1):
# 取出所有t时间的订单
id_list = [id_[1] for id_ in orders if id_[0] == t]
for storeID in hash_dict.keys():
orderCount = id_list.count(storeID)
if orderCount == 0:
hash_dict[storeID] = max(0, hash_dict[storeID] - 1)
else:
hash_dict[storeID] += orderCount*2
if hash_dict[storeID] > 5:
priority_list[storeID] = 1
elif hash_dict[storeID] <= 3:
priority_list[storeID] = 0
# print(hash_dict)
print(sum(priority_list))