import sys
input = sys.stdin.readline

def main():
  n, m = map(int, input().split())
  road = [[100000]*n for _ in range(n)]
  for _ in range(m):
    a, b, c = map(int, input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c
  ans = 0
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if road[i][k]+road[k][j] < road[i][j]:
          if road[i][j] != 100000:
            ans += 1
          road[i][j] = road[i][k]+road[k][j]
  print(ans//2)
  
  
  
if __name__ == "__main__":
  main()