#include <bits/stdc++.h>
using namespace std;
inline void read() {}
template <typename T, typename... Ts>
inline void read(T& A, Ts&... As) {
  T x = 0, f = 1;
  char ch = getchar();
  while (!(ch & 16)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch & 16) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  A = x * f, read(As...);
}
long long n, m, u, v;
long long k, res = 1;
struct node {
  long long id, d;
};
struct edge {
  long long to, val;
};
bool operator<(node a, node b) { return a.d > b.d; }
const long long N = 600010;
vector<edge> a[N], ch[N];
long long d[N], vis[N], e[N];
long long st[N], ed[N], w[N];
priority_queue<node> q;
long long chked[N];
signed main() {
  read(n, m, k);
  for (register long long i = 1; i <= m; ++i) {
    read(u, v, w[i]), e[i] = u ^ v, st[i] = u, ed[i] = v;
    a[u].push_back(edge{i, w[i]}), a[v].push_back(edge{i, w[i]});
  }
  for (register long long i = m + 1; i <= m + k; ++i) {
    u = 1, read(v, w[i]), e[i] = u ^ v, st[i] = u, ed[i] = v;
    a[u].push_back(edge{i, w[i]}), a[v].push_back(edge{i, w[i]});
  }
  for (register long long i = 1; i <= n; ++i) d[i] = 1e18;
  d[1] = 0, q.push(node{1, 0});
  while (!q.empty()) {
    long long x = q.top().id;
    q.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    for (register long long i = 0; i < a[x].size(); i++) {
      long long to = e[a[x][i].to] ^ x, val = a[x][i].val;
      if (d[to] > d[x] + val) {
        d[to] = d[x] + val;
        if (!vis[to]) q.push(node{to, d[to]});
      }
    }
  }
  long long ans = n - 1;
  for (register long long i = 1; i <= m; ++i) {
    if (d[st[i]] > d[ed[i]]) swap(st[i], ed[i]);
    if (!chked[ed[i]] && d[ed[i]] == d[st[i]] + w[i]) chked[ed[i]] = 1, --ans;
  }
  cout << max(0ll, k - ans);
  return 0;
}
