#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
const int INF = 1 << 30;
int d[105][105], a[1005], b[1005], c[1005];
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  for (int i = 0; i < (105); i++)
    for (int j = 0; j < (105); j++) d[i][j] = INF;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (m); i++) {
    int tmp_a, tmp_b, tmp_c;
    cin >> tmp_a >> tmp_b >> tmp_c;
    tmp_a--;
    tmp_b--;
    d[tmp_a][tmp_b] = tmp_c;
    d[tmp_b][tmp_a] = tmp_c;
    a[i] = tmp_a;
    b[i] = tmp_b;
    c[i] = tmp_c;
  }
  warshall_floyd(n);
  int ans = 0;
  for (int i = 0; i < (m); i++) {
    bool shortest = false;
    for (int j = 0; j < (n); j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) shortest = true;
    }
    if (!shortest) ans++;
  }
  cout << ans << endl;
  return 0;
}
