#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (int i = 0; i < ((int)v.size()); ++i) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename T, size_t S>
void printArray(const T (&array)[S]) {
  for (auto val : array) std::cout << val << ", ";
  std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  int n, m;
  std::cin >> n >> m;
  vvi to(n, vi(n, inf)), cost;
  for (int i = 0; i < (n); ++i) to[i][i] = 0;
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    std::cin >> a >> b >> c;
    --a, --b;
    to[a][b] = to[b][a] = c;
  }
  cost = to;
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j)
        (cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]));
  set<pi> walked;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) {
      int s = i, g = j, cur = i;
      while (cur != g) {
        for (int k = 0; k < (n); ++k) {
          if (k == cur || to[cur][k] + cost[k][g] != cost[cur][g]) continue;
          walked.insert({min(cur, k), max(cur, k)});
          cur = k;
          break;
        }
      }
    }
  std::cout << m - (int)walked.size() << "\n";
}
