#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7,
          around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const long long LINF = 1e18;
const long double PI = abs(acos(-1));
int n, m, a, b, c, lia[110], lib[110];
vector<pair<long long, long long>> g[110];
long long dijkstra(int s, int t) {
  long long min_cost[100010] = {};
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  for (int i = (0); i < (n); i++) min_cost[i] = INF;
  que.emplace(0, s);
  min_cost[s] = 0;
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    if (p.first > min_cost[p.second]) continue;
    for (auto e : g[p.second]) {
      if (p.first + e.second >= min_cost[e.first]) continue;
      min_cost[e.first] = p.first + e.second;
      que.emplace(min_cost[e.first], e.first);
    }
  }
  return min_cost[t];
}
long long find(int s, bool f) {
  long long min_cost[100010] = {};
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  for (int i = (0); i < (n); i++) min_cost[i] = INF;
  que.emplace(0, s);
  min_cost[s] = 0;
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    if (p.first > min_cost[p.second]) continue;
    for (auto e : g[p.second]) {
      if (p.first + e.second >= min_cost[e.first]) continue;
      min_cost[e.first] = p.first + e.second;
      que.emplace(min_cost[e.first], e.first);
    }
  }
  if (f)
    for (int i = (0); i < (n); i++) lia[i] = min_cost[i];
  else
    for (int i = (0); i < (n); i++) lib[i] = min_cost[i];
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = (0); i < (m); i++)
    cin >> a >> b >> c,
        g[a - 1].push_back(pair<long long, long long>(b - 1, c)),
        g[b - 1].push_back(pair<long long, long long>(a - 1, c));
  set<pair<long long, long long>> cou;
  for (int i = (0); i < (n); i++) {
    for (int j = (i + 1); j < (n); j++) {
      int minc = dijkstra(i, j);
      set<int> st;
      queue<int> qu;
      find(i, 0);
      find(j, 1);
      qu.push(i);
      st.insert(i);
      while (!qu.empty()) {
        auto p = qu.front();
        qu.pop();
        if (p == j) break;
        for (auto e : g[p]) {
          if (st.count(e.first)) continue;
          if (lia[e.first] + lib[e.first] == minc) {
            cou.insert(make_pair(min<long long>(p, e.first),
                                 max<long long>(p, e.first)));
            qu.push(e.first);
            st.insert(e.first);
            break;
          }
        }
      }
    }
  }
  cout << m - cou.size() << endl;
  return 0;
}
