#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 56;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> r(n, vector<long long>(n, INF));
  for (int(i) = 0; (i) < (n); (i)++) r[i][i] = 0;
  for (int(i) = 0; (i) < (m); (i)++) {
    int a, b, c;
    cin >> a >> b >> c;
    r[a - 1][b - 1] = r[b - 1][a - 1] = c;
  }
  vector<vector<int>> ck(n, vector<int>(n, 0));
  auto og = r;
  for (int(k) = 0; (k) < (n); (k)++)
    for (int(i) = 0; (i) < (n); (i)++)
      for (int(j) = 0; (j) < (n); (j)++)
        r[i][j] = min(r[i][j], r[i][k] + r[k][j]);
  for (int(s) = 0; (s) < (n); (s)++)
    for (int(g) = (s + 1); (g) < (n); (g)++) {
      for (int cr = s; cr != g;) {
        for (int(i) = 0; (i) < (n); (i)++)
          if (i != cr && r[cr][g] == og[cr][i] + r[i][g]) {
            ck[cr][i] = ck[i][cr] = 1;
            cr = i;
            break;
          }
      }
    }
  long long ans = 0;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = (i + 1); (j) < (n); (j)++) {
      if (og[i][j] < INF && ck[i][j] == 0) ans++;
    }
  cout << ans << endl;
  return 0;
}
