#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
string converter(T n) {
  stringstream x;
  x << n;
  return x.str();
}
string itos(int a) {
  string s = to_string(a);
  return s;
}
string itos(long long a) {
  string s = to_string(a);
  return s;
}
template <class T>
T mod_pow(T x, T n) {
  T res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    n >>= 1;
  }
  return res;
}
std::vector<std::string> split(const std::string &str, char sep) {
  std::vector<std::string> v;
  std::stringstream ss(str);
  std::string buffer;
  while (std::getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}
struct edge {
  int from, to;
  long long cost;
};
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
bool mysort(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
bool _mysort(pair<char, int> a, pair<char, int> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else {
    return a.first < b.first;
  }
}
int V;
int d[1000][1000];
int main(void) {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int m;
  cin >> V >> m;
  vector<edge> g;
  for (int i = 0; i < 1000; i++)
    for (int j = 0; j < 1000; j++) d[i][j] = ((i != j) ? 100000 : 0);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    edge e;
    cin >> a >> b >> c;
    a--;
    b--;
    e.from = a;
    e.to = b;
    e.cost = c;
    g.push_back(e);
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      for (int k = 0; k < V; k++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = m;
  bool b[V][V];
  for (auto &j : g) {
    bool flag = false;
    for (int i = 0; i < V; i++) {
      if (d[i][j.from] + j.cost == d[i][j.to]) flag = true;
    }
    if (flag) {
      ans--;
    }
  }
  cout << ans << '\n';
  return 0;
}
