#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[111111];
bool used[111111];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    --x;
    --y;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
  }
  int ans = 0;
  vector<int> rw(n, -1);
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    if (rw[x] != -1) {
      ans++;
      rw[x] = min(rw[x], y);
    } else {
      rw[x] = y;
    }
  }
  vector<long long> d(n, 1e18);
  priority_queue<pair<long long, int> > q;
  d[0] = 0;
  q.push({0, 0});
  for (int i = 0; i < n; i++) {
    if (rw[i] != -1) {
      d[i] = rw[i];
      q.push({-d[i], i});
    }
  }
  while (!q.empty()) {
    auto v = q.top();
    q.pop();
    int from = v.second;
    if (used[from]) {
      continue;
    }
    used[from] = true;
    for (auto& i : g[from]) {
      if (d[i.first] > d[from] + i.second) {
        d[i.first] = d[from] + i.second;
        q.push(make_pair(-d[i.first], i.first));
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (rw[i] == -1) {
      continue;
    }
    for (auto& v : g[i]) {
      if (d[i] == d[v.first] + v.second) {
        ans++;
        break;
      }
    }
  }
  cout << ans;
  return 0;
}
