#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9 + 7;
const int INF = 100000000;
const ll LINF = (ll)1e18;
using Graph = vector<vector<P>>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  map<string, int> d;
  int N, M;
  cin >> N >> M;
  int A[1000], B[1000], C[1000], mp[100][100];
  for (int(i) = 0; (i) < (N); (i)++) {
    for (int(j) = 0; (j) < (N); (j)++) {
      if (i == j) {
        mp[i][i] = 0;
      } else {
        mp[i][i] = INF;
      }
    }
  }
  for (int(i) = 0; (i) < (M); (i)++) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    mp[A[i]][B[i]] = C[i];
    mp[B[i]][A[i]] = C[i];
  }
  for (int(i) = 0; (i) < (M); (i)++) {
    mp[A[i]][B[i]] = min(mp[A[i]][B[i]], C[i]);
    mp[B[i]][A[i]] = min(mp[B[i]][A[i]], C[i]);
  }
  for (int(k) = 0; (k) < (N); (k)++) {
    for (int(i) = 0; (i) < (N); (i)++) {
      for (int(j) = 0; (j) < (N); (j)++) {
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
      }
    }
  }
  int ans = M;
  for (int(i) = 0; (i) < (M); (i)++) {
    bool shortest = false;
    for (int(j) = 0; (j) < (N); (j)++) {
      if (mp[j][A[i]] + C[i] == mp[j][B[i]]) {
        shortest = true;
      }
    }
    if (shortest == true) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
