#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void debug_out() { std::cout << std::endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
struct Edge {
  int to;
  ll weight;
  Edge(int t, ll w) : to(t), weight(w) {}
};
struct edge {
  int from;
  int to;
  ll weight;
  edge(int f, int t, ll w) : from(f), to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
bool isPalindrome(string s) {
  string t = s;
  reverse((t).begin(), (t).end());
  return s == t;
}
constexpr ll LNF = 9223372036854775807LL;
constexpr int INF = 1e9 + 7;
const double PI = 3.14159265358979323846;
vector<int> dx = {-1, 0, 1, 0, -1, 1, -1, 1};
vector<int> dy = {0, -1, 0, 1, 1, -1, -1, 1};
std::vector<std::vector<ll>> d;
void warshall_floyd(int n) {
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(n); j++) {
      for (int k = (int)(0); k < (int)(n); k++) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  d.resize(n);
  for (int i = (int)(0); i < (int)(n); i++) {
    d[i].resize(n);
    d[i][i] = 0;
  }
  vector<int> a(m), b(m), c(m);
  for (int i = (int)(0); i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  warshall_floyd(n);
  vector<int> e(m, 0);
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(m); j++) {
      if (d[i][a[i]] + c[i] == d[i][b[i]]) {
        e[i]++;
      }
    }
  }
  int ans = 0;
  for (int i = (int)(0); i < (int)(m); i++) {
    if (e[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}
