#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
struct Edge {
  long long int to, weight;
  Edge(long long int t, long long int w) : to(t), weight(w) {}
};
using graph = vector<vector<long long int>>;
using Graph = vector<vector<Edge>>;
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int keta(long long int N) {
  long long int M = 1;
  while (N > 0) {
    if (N / 10 == 0) {
      break;
    }
    N /= 10;
    M++;
  }
  return M;
}
bool kai(string S) {
  bool flag = true;
  for (long long int i = 0; i < S.size() / 2; ++i) {
    if (S[i] != S[S.size() - i - 1]) {
      flag = false;
      break;
    }
  }
  return flag;
}
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int g[n][n];
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < n; ++j) {
      if (i == j) {
        g[i][j] = 0;
      } else {
        g[i][j] = INF;
      }
    }
  }
  vector<long long int> a(m), b(m), c(m);
  for (long long int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    g[a[i]][b[i]] = c[i];
    g[b[i]][a[i]] = c[i];
  }
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < n; ++j) {
      for (long long int k = 0; k < n; ++k) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  long long int ans = m;
  for (long long int i = 0; i < m; ++i) {
    bool flag = false;
    for (long long int j = 0; j < n; ++j) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) {
        flag = true;
      }
    }
    if (flag) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
