#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool maxup(T& a, T&& b) {
  if (a < b) {
    a = b;
    return true;
  };
}
template <typename T>
bool maxup(T& a, T& b) {
  if (a < b) {
    a = b;
    return true;
  };
}
template <typename T>
bool minup(T& a, T&& b) {
  if (a > b) {
    a = b;
    return true;
  };
}
template <typename T>
bool minup(T& a, T& b) {
  if (a > b) {
    a = b;
    return true;
  };
}
using VV = vector<vector<long long>>;
using V = vector<long long>;
using P = pair<long long, long long>;
using IP = pair<long long, P>;
template <typename T>
inline void input(vector<T>& v) {
  for (auto& x : v) cin >> x;
}
long long g[101][101];
bool used[101][101];
long long ex[101][101];
signed main() {
  long long N, M;
  cin >> N >> M;
  for (signed i = signed(0); i < signed(N); i++)
    for (signed j = signed(0); j < signed(N); j++) g[i][j] = 1 << 29;
  for (signed i = signed(0); i < signed(M); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = c;
    ex[a][b] = ex[b][a] = c;
  }
  for (signed k = signed(0); k < signed(N); k++)
    for (signed i = signed(0); i < signed(N); i++)
      for (signed j = signed(0); j < signed(N); j++)
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  for (signed i = signed(0); i < signed(N); i++)
    for (signed j = signed(0); j < signed(N); j++)
      for (signed k = signed(0); k < signed(N); k++)
        if (g[i][k] + g[k][j] == g[i][j])
          used[i][k] = used[j][k] = true;
        else if (g[i][j] == ex[i][j])
          used[i][j] = true;
  for (signed i = signed(0); i < signed(N); i++)
    for (signed j = signed(i + 1); j < signed(N); j++)
      if (ex[i][j]) M -= used[i][j];
  cout << M << endl;
  system("pause");
}
