#include <bits/stdc++.h>
using namespace std;
int graph[100][100];
bool isused[100][100];
int counts;
void search(int n) {
  for (int i = 0; i < n; i++) {
    for (int s = 0; s < n; s++) {
      for (int g = 0; g < n; g++) {
        if ((graph[s][g] < graph[s][i] + graph[i][g])) {
          if (isused[s][g] == false) {
            isused[s][g] = true;
          }
        } else {
          if (isused[s][i] == false) {
            isused[s][i] = true;
          }
          if (isused[i][g] == false) {
            isused[i][g] = true;
          }
        }
        graph[s][g] = min(graph[s][g], graph[s][i] + graph[i][g]);
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      graph[i][j] = 987654321;
      isused[i][j] = true;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a][b] = c;
    graph[b][a] = c;
    isused[a][b] = false;
    isused[b][a] = false;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
    }
  }
  search(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (isused[i][j] == false) {
        ans++;
      }
    }
  }
  ans /= 2;
  cout << ans << endl;
  return 0;
}
