#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int g[114][114];
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> A, B;
  for (int i = 0; i < (114); ++i)
    for (int j = 0; j < (114); ++j) g[i][j] = INF;
  for (int i = 0; i < (114); ++i) g[i][i] = 0;
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    A.push_back(a);
    B.push_back(b);
    g[a][b] = g[b][a] = c;
  }
  int t[114][114] = {};
  for (int i = 0; i < (114); ++i)
    for (int j = 0; j < (114); ++j) t[i][j] = g[i][j];
  for (int k = 0; k < (114); ++k)
    for (int i = 0; i < (114); ++i)
      for (int j = 0; j < (114); ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  long long cnt = 0;
  for (int i = 0; i < (n); ++i) {
    int edge = t[A[i]][B[i]];
    bool used = false;
    for (int j = 0; j < (n); ++j) {
      for (int k = 0; k < (n); ++k) {
        int dist = g[j][A[i]] + edge + g[B[i]][k];
        if (dist == g[j][k]) used = true;
      }
    }
    if (!used) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
