from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())

s=[[float('inf')]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    s[i][j]=0

l=[]
for i in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  s[a][b]=c
  s[b][a]=c
  l.append([a,b])

wf,p=floyd_warshall(s,return_predecessors=True)

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])

def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]


for i in range(n-1):
  for j in range(i+1,n):
    min_l=get_path(i,j,p)
    for k in range(len(min_l)-1):
      hen1=[min_l[k+1],min_l[k]]
      hen2=[min_l[k],min_l[k+1]]
      if hen1 in l:
        l.remove(hen1)
      elif hen2 in l:
        l.remove(hen2)

print(len(l))