#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1e9;
const long long INFLL = 1e18;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
class Graph {
 public:
  struct edge {
    int to;
    T cost;
    int id;
  };
  int N;
  vector<vector<edge>> G;
  vector<vector<T>> d;
  Graph(int _N) : N(_N) {
    G = vector<vector<edge>>(N, vector<edge>(0));
    d = vector<vector<long long>>(N, vector<long long>(N));
  }
  void add_Directed_edge(int from, int to, T cost = 1, int id = 0) {
    G[from].push_back(edge({to, cost, id}));
  }
  void add_Undirected_edge(int v1, int v2, T cost = 1, int id = 0) {
    add_Directed_edge(v1, v2, cost, id);
    add_Directed_edge(v2, v1, cost, id);
  }
  void WarshallFloyd() {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; j++) {
        d[i][j] = ((i == j) ? 0 : INFLL);
      }
    }
    for (int i = 0; i < N; ++i) {
      for (auto e : G[i]) {
        d[i][e.to] = e.cost;
      }
    }
    for (int k = 0; k < N; ++k) {
      for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }
  void debug() {
    for (int i = 0; i < N; ++i) {
      cerr << i + 1 << ": ";
      for (edge e : G[i]) {
        cerr << "{" << e.to + 1 << ", " << e.cost << "}, ";
      }
      cerr << endl;
    }
    cerr << endl << "distance_matrix" << endl;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (d[i][j] == INFLL) {
          cerr << -1 << " ";
        } else
          cerr << d[i][j] << " ";
      }
      cerr << endl;
    }
  }
};
int a[100], b[100], c[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N, M;
  cin >> N >> M;
  Graph<long long> G(N);
  for (int i = 0; i < int(M); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G.add_Undirected_edge(a[i], b[i], c[i], i);
  }
  G.WarshallFloyd();
  int ans = M;
  for (int i = 0; i < int(M); ++i) {
    bool shortest = false;
    for (int j = 0; j < int(N); ++j) {
      if (G.d[j][a[i]] + c[i] == G.d[j][b[i]]) {
        shortest = true;
      }
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
}
