#include <bits/stdc++.h>
using namespace std;
int hako[110][110];
int prehako[110][110];
int flag[110][110];
int main() {
  for (int i = 0; i < 110; i++) fill(hako[i], hako[i] + 110, 1000000000);
  for (int i = 0; i < 110; i++) fill(prehako[i], prehako[i] + 110, i);
  for (int i = 0; i < 110; i++) fill(flag[i], flag[i] + 110, -1);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    hako[a - 1][b - 1] = c;
    hako[b - 1][a - 1] = c;
    flag[a - 1][b - 1] = c;
    flag[b - 1][a - 1] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (hako[i][j] > hako[i][k] + hako[k][j]) {
          hako[i][j] = hako[i][k] + hako[k][j];
          prehako[i][j] = prehako[k][j];
        }
      }
    }
  }
  int res = m;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (flag[k][j] == -1) continue;
        if (hako[i][j] == hako[i][k] + flag[k][j]) {
          res--;
          flag[k][j] = -1;
          flag[j][k] = -1;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
