#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  int d[N][N];
  int next[N][N];
  for (int i = 0; i < (M); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (N); ++j) next[i][j] = j;
  for (int k = 0; k < (N); ++k)
    for (int i = 0; i < (N); ++i)
      for (int j = 0; j < (N); ++j)
        if (d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
          next[i][j] = next[i][k];
        }
  set<pair<int, int>> st;
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (N); ++j)
      if (i > j) {
        if (i > next[i][j])
          st.insert(make_pair(i, next[i][j]));
        else
          st.insert(make_pair(next[i][j], i));
      }
  cout << (max(0, M - (int)st.size())) << '\n';
}
