#include <bits/stdc++.h>
using namespace std;
int d[101][101];
int n, m;
int dis[101][101];
bool bo[101][101];
void saitan(int s) {
  queue<int> q;
  q.push(s);
  dis[s][s] = 0;
  for (int i = 0; i < n; i++) {
    int x = q.front();
    q.pop();
    bo[s][x] = true;
    int m = 1000000;
    for (int j = 1; j <= n; j++) {
      if (d[x][j] >= 0) {
        if (dis[s][j] > dis[s][x] + d[x][j]) dis[s][j] = dis[s][x] + d[x][j];
      }
      if (bo[s][j] == false) {
        m = min(dis[s][j], m);
      }
    }
    for (int j = 1; j <= n; j++) {
      if (dis[s][j] == m) {
        q.push(j);
        break;
      }
    }
  }
}
int main() {
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      d[i][j] = -1;
      dis[i][j] = 100000000;
    }
  }
  for (int i = 0; i < 101; i++)
    for (int j = 0; j < 101; j++) bo[i][j] = false;
  cin >> n >> m;
  int a[m], b[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    saitan(i);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      if (d[a[i]][b[i]] >= dis[a[i]][j] + dis[j][b[i]]) {
        sum++;
        break;
      }
    }
  }
  cout << sum << endl;
}
