//449B

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+10;

int n, m, k;
vector<ii> edges[N];
int W[N];
int relaxed[200010];
int par[N];
vector<ll> dist;

void dijkstra(){
	priority_queue<ii, vector<ii>, greater<ii> > Q;
	Q.push(mp(0,1));
	dist.assign(N, INF);
	dist[1] = 0;
	while (!Q.empty()){
		ii tmp = Q.top();
		Q.pop();
		if (dist[tmp.second] != tmp.first)
			continue;
		for (vector<ii>::iterator it = edges[tmp.second].begin(); it != edges[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.second];
				Q.push(mp(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m)
					par[it -> first] = it -> second;
			}
		}
	}
	return;
}

int main (void){
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i,1,m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		edges[a].pb(mp(b,i));
		edges[b].pb(mp(a,i));
		W[i] = c;
	}
	FOR(i,1,k){
		int a;
		ll c;
		cin >> a >> c;
		edges[1].pb(mp(a,i + m));
		edges[a].pb(mp(1,i + m));
		W[i + m] = c;
	}
	dijkstra();
	FOR(i,1,m + k){
		if (par[i] == -1)
			continue;
		relaxed[par[i]] = 1;
	}
	ll tot = 0;
	FOR(i,m + 1,m + k){
		if (!relaxed[i]) tot++;
	}
	cout << tot << endl;
}


//449B

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = (3 * 1e5) +10;

int n, m, k;
vector<ii> edges[N];
int W[N];
int relaxed[200010];
int par[N];
vector<ll> dist;

void dijkstra(){
	priority_queue<ii, vector<ii>, greater<ii> > Q;
	Q.push(mp(0,1));
	dist.assign(N, INF);
	dist[1] = 0;
	while (!Q.empty()){
		ii tmp = Q.top();
		Q.pop();
		if (dist[tmp.second] != tmp.first)
			continue;
		for (vector<ii>::iterator it = edges[tmp.second].begin(); it != edges[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.second];
				Q.push(mp(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m)
					par[it -> first] = it -> second;
			}
		}
	}
	return;
}

int main (void){
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i,1,m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		edges[a].pb(mp(b,i));
		edges[b].pb(mp(a,i));
		W[i] = c;
	}
	FOR(i,1,k){
		int a;
		ll c;
		cin >> a >> c;
		edges[1].pb(mp(a,i + m));
		edges[a].pb(mp(1,i + m));
		W[i + m] = c;
	}
	dijkstra();
	FOR(i,1,m + k){
		if (par[i] == -1)
			continue;
		relaxed[par[i]] = 1;
	}
	ll tot = 0;
	FOR(i,m + 1,m + k){
		if (!relaxed[i]) tot++;
	}
	cout << tot << endl;
}


//449B

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = (4 * 1e5) +10;

int n, m, k;
vector<ii> edges[N];
int W[N];
int relaxed[N];
int par[N];
vector<ll> dist;

void dijkstra(){
	priority_queue<ii, vector<ii>, greater<ii> > Q;
	Q.push(mp(0,1));
	dist.assign(N, INF);
	dist[1] = 0;
	while (!Q.empty()){
		ii tmp = Q.top();
		Q.pop();
		if (dist[tmp.second] != tmp.first)
			continue;
		for (vector<ii>::iterator it = edges[tmp.second].begin(); it != edges[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.second];
				Q.push(mp(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m)
					par[it -> first] = it -> second;
			}
		}
	}
	return;
}

int main (void){
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i,1,m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		edges[a].pb(mp(b,i));
		edges[b].pb(mp(a,i));
		W[i] = c;
	}
	FOR(i,1,k){
		int a;
		ll c;
		cin >> a >> c;
		edges[1].pb(mp(a,i + m));
		edges[a].pb(mp(1,i + m));
		W[i + m] = c;
	}
	dijkstra();
	FOR(i,1,m + k){
		if (par[i] == -1)
			continue;
		relaxed[par[i]] = 1;
	}
	ll tot = 0;
	FOR(i,m + 1,m + k){
		if (!relaxed[i]) tot++;
	}
	cout << tot << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <Int, int> PLI;
typedef pair <double, double> PDD;

const Int INF = 1e18;
const int MAX = 1000007;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;

const int MOD = 1234567891;

int n, m, k;
vector<PLI> G[400005];
int W[400005];
vector<Int> dist;
int par[400005], relaxed[400005];

void dijkstra(){
	priority_queue <PLI, vector<PLI>, greater<PLI> > Q;
	dist.assign(400005, INF);
	Q.push(MP(0,1));
	dist[1] = 0;
	while (!Q.empty()){
		//cout << "here" << endl;
		PLI tmp = Q.top();
		Q.pop();
		if (tmp.first != dist[tmp.second]) continue;
		for (vector<PLI>::iterator it = G[tmp.second].begin(); it != G[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.second];
				Q.push(MP(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m) par[it -> first] = it -> second;
			}
		}
	}
	return;
}

int main() {
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i, 1, m + 1){
		int a, b;
		Int c;
		cin >> a >> b >> c;
		G[a].PB(MP(b,i));
		G[b].PB(MP(a,i));
		W[i] = c;
	}
	FOR(i, 1, k + 1){
		int a;
		Int b;
		cin >> a >> b;
		G[1].PB(MP(a,i + m));
		G[a].PB(MP(1, i + m));
		W[i + m] = b;
	}
	dijkstra();
	//cout << "done" << endl;
	Int tot = 0;
	FOR(i, 1, k + m + 1){
		if (par[i] == -1) continue;
		relaxed[par[i]] = 1;
	}
	FOR(i, m + 1, k + m + 1){
		if (!relaxed[i]) ++tot;
	}
	cout << tot << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <Int, int> PLI;
typedef pair <double, double> PDD;

const Int INF = 1e18;
const int MAX = 1000007;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;

const int MOD = 1234567891;

int n, m, k;
vector<PLI> G[400005];
int W[400005];
vector<Int> dist;
int par[400005], relaxed[400005];

void dijkstra(){
	priority_queue <PLI, vector<PLI>, greater<PLI> > Q;
	dist.assign(400005, INF);
	Q.push(MP(0,1));
	dist[1] = 0;
	while (!Q.empty()){
		PLI tmp = Q.top();
		Q.pop();
		if (tmp.first != dist[tmp.second]) continue;
		for (vector<PLI>::iterator it = G[tmp.second].begin(); it != G[tmp.second].end(); ++it){
			if (W[it -> second] + tmp.first < dist[tmp.second]){
				dist[tmp.second] = W[it -> second] + tmp.first;
				Q.push(MP(dist[tmp.second], it -> first));
				par[it -> first] = tmp.second;
			}
			else if (W[it -> second] + tmp.first == dist[tmp.second]){
				if (it -> second <= m) par[it -> second] = tmp.second;
			}
		}
	}
}

int main() {
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i, 1, m + 1){
		int a, b;
		Int c;
		cin >> a >> b >> c;
		G[a].PB(MP(b,i));
		G[b].PB(MP(a,i));
		W[i] = c;
	}
	FOR(i, 1, k + 1){
		int a;
		Int b;
		cin >> a >> b;
		G[1].PB(MP(a,i + m));
		G[a].PB(MP(1, i + m));
		W[i + m] = b;
	}
	dijkstra();
	Int tot = 0;
	FOR(i, 1, k + m){
		if (par[i] == -1) continue;
		relaxed[par[i]] = 1;
	}
	FOR(i, m + 1, k + m){
		if (!relaxed[i]) ++tot;
	}
	cout << tot << endl;
	return 0;
}


//449B

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = (3 * 1e5) +10;

int n, m, k;
vector<ii> edges[N];
int W[N];
int relaxed[200010];
int par[N];
vector<ll> dist;

void dijkstra(){
	priority_queue<ii, vector<ii>, greater<ii> > Q;
	Q.push(mp(0,1));
	dist.assign(N, INF);
	dist[1] = 0;
	while (!Q.empty()){
		ii tmp = Q.top();
		Q.pop();
		if (dist[tmp.second] != tmp.first)
			continue;
		for (vector<ii>::iterator it = edges[tmp.second].begin(); it != edges[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.second];
				Q.push(mp(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m)
					par[it -> first] = it -> second;
			}
		}
	}
	return;
}

int main (void){
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i,1,m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		edges[a].pb(mp(b,i));
		edges[b].pb(mp(a,i));
		W[i] = c;
	}
	FOR(i,1,k){
		int a;
		ll c;
		cin >> a >> c;
		edges[1].pb(mp(a,i + m));
		edges[a].pb(mp(1,i + m));
		W[i + m] = c;
	}
	dijkstra();
	FOR(i,1,m + k){
		cout << par[i] << endl;
	}
	FOR(i,1,m + k){
		if (par[i] == -1)
			continue;
		relaxed[par[i]] = 1;
	}
	ll tot = 0;
	FOR(i,m + 1,m + k){
		if (!relaxed[i]) tot++;
	}
	cout << tot << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <Int, int> PLI;
typedef pair <double, double> PDD;

const Int INF = 1e18;
const int MAX = 1000007;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;

const int MOD = 1234567891;

int n, m, k;
vector<PLI> G[400005];
int W[400005];
vector<Int> dist;
int par[400005], relaxed[400005];

void dijkstra(){
	priority_queue <PLI, vector<PLI>, greater<PLI> > Q;
	dist.assign(400005, INF);
	Q.push(MP(0,1));
	dist[1] = 0;
	while (!Q.empty()){
		PLI tmp = Q.top();
		Q.pop();
		if (tmp.first != dist[tmp.second]) continue;
		for (vector<PLI>::iterator it = G[tmp.second].begin(); it != G[tmp.second].end(); ++it){
			if (W[it -> second] + tmp.first < dist[tmp.second]){
				dist[tmp.second] = W[it -> second] + tmp.first;
				Q.push(MP(dist[tmp.second], it -> first));
				par[it -> first] = tmp.second;
			}
			else if (W[it -> second] + tmp.first == dist[tmp.second]){
				if (it -> second <= m) par[it -> first] = it -> second;
			}
		}
	}
}

int main() {
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i, 1, m + 1){
		int a, b;
		Int c;
		cin >> a >> b >> c;
		G[a].PB(MP(b,i));
		G[b].PB(MP(a,i));
		W[i] = c;
	}
	FOR(i, 1, k + 1){
		int a;
		Int b;
		cin >> a >> b;
		G[1].PB(MP(a,i + m));
		G[a].PB(MP(1, i + m));
		W[i + m] = b;
	}
	dijkstra();
	Int tot = 0;
	FOR(i, 1, k + m){
		if (par[i] == -1) continue;
		relaxed[par[i]] = 1;
	}
	FOR(i, m + 1, k + m){
		if (!relaxed[i]) ++tot;
	}
	cout << tot << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <Int, int> PLI;
typedef pair <double, double> PDD;

const Int INF = 1e18;
const int MAX = 1000007;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;

const int MOD = 1234567891;

int n, m, k;
vector<PLI> G[400005];
int W[400005];
vector<Int> dist;
int par[400005], relaxed[400005];

void dijkstra(){
	priority_queue <PLI, vector<PLI>, greater<PLI> > Q;
	dist.assign(400005, INF);
	Q.push(MP(0,1));
	dist[1] = 0;
	while (!Q.empty()){
		PLI tmp = Q.top();
		Q.pop();
		if (tmp.first != dist[tmp.second]) continue;
		for (vector<PLI>::iterator it = G[tmp.second].begin(); it != G[tmp.second].end(); it++){
			if (W[it -> second] + dist[tmp.second] < dist[it -> first]){
				dist[it -> first] = W[it -> second] + dist[tmp.first];
				Q.push(MP(dist[it -> first], it -> first));
				par[it -> first] = it -> second;
			}
			else if (W[it -> second] + dist[tmp.second] == dist[it -> first]){
				if (it -> second <= m) par[it -> first] = it -> second;
			}
		}
	}
}

int main() {
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i, 1, m + 1){
		int a, b;
		Int c;
		cin >> a >> b >> c;
		G[a].PB(MP(b,i));
		G[b].PB(MP(a,i));
		W[i] = c;
	}
	FOR(i, 1, k + 1){
		int a;
		Int b;
		cin >> a >> b;
		G[1].PB(MP(a,i + m));
		G[a].PB(MP(1, i + m));
		W[i + m] = b;
	}
	dijkstra();
	Int tot = 0;
	FOR(i, 1, k + m){
		if (par[i] == -1) continue;
		relaxed[par[i]] = 1;
	}
	FOR(i, m + 1, k + m){
		if (!relaxed[i]) ++tot;
	}
	cout << tot << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <Int, int> PLI;
typedef pair <double, double> PDD;

const Int INF = 1e18;
const int MAX = 1000007;
const int MAX1 = 2007;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;

const int MOD = 1234567891;

int n, m, k;
vector<PLI> G[400005];
int W[400005];
vector<Int> dist;
int par[400005];

void dijkstra(){
	priority_queue <PLI, vector<PLI>, greater<PLI> > Q;
	dist.assign(400005, INF);
	Q.push(MP(0,1));
	dist[1] = 0;
	while (!Q.empty()){
		PLI tmp = Q.top();
		Q.pop();
		if (tmp.first != dist[tmp.second]) continue;
		for (vector<PLI>::iterator it = G[tmp.second].begin(); it != G[tmp.second].end(); ++it){
			if (W[it -> second] + tmp.first < dist[tmp.second]){
				dist[tmp.second] = W[it -> second] + tmp.first;
				Q.push(MP(dist[tmp.second], it -> first));
				par[it -> first] = tmp.second;
			}
			else if (W[it -> second] + tmp.first == dist[tmp.second]){
				if (it -> second <= m) par[it -> second] = tmp.second;
			}
		}
	}
}

int main() {
	memset(par, -1, sizeof(par));
	cin >> n >> m >> k;
	FOR(i, 1, m + 1){
		int a, b;
		Int c;
		cin >> a >> b >> c;
		G[a].PB(MP(b,i));
		G[b].PB(MP(a,i));
		W[i] = c;
	}
	FOR(i, 1, k + 1){
		int a;
		Int b;
		cin >> a >> b;
		G[1].PB(MP(a,i + m));
		G[a].PB(MP(1, i + m));
		W[i + m] = b;
	}
	dijkstra();
	Int tot = 0;
	FOR(i, m + 1, k + m){
		if (par[i] == -1) ++tot;
	}
	cout << tot << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
vector <pair<int,ll>> train;

void dijkstra(int s)
{
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    q.push(mp(0,s));
    while(!q.empty())
    {
        int v=q.top().S;
        ll dist = q.top().F;
        q.pop();
        if(dist>d[v])
            continue;
        if(dist==INF)
            return;
        for(auto edge : adj[v])
        {
            int to = edge.F;
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;
    rep(i,0,m)
    {
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].pb(mp(b,c));
        adj[b].pb(mp(a,c));
    }
    rep(i,0,k)
    {
        int a;ll b;
        cin>>a>>b;
        train.pb(mp(a,b));
        adj[1].pb(mp(a,b));
        adj[a].pb(mp(1,b));
    }

    dijkstra(1);

    int ans=0;
    rep(i,0,k)
    {
        if(d[train[i].F]<=train[i].S)
            ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];

void dijkstra(int s)
{
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    q.push(mp(0,s));
    while(!q.empty())
    {
        int v=q.top().S;
        ll dist = q.top().F;
        q.pop();
        if(dist>d[v])
            continue;
        if(dist==INF)
            return;
        for(auto edge : adj[v])
        {
            int to = edge.F;
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;
    rep(i,0,m)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(mp(b,c));
        adj[b].pb(mp(a,c));
    }

    dijkstra(1);
    int ans=0;
    rep(i,0,k)
    {
        int a;ll b;cin>>a>>b;
        if(d[a]<=b)
            ans++;
    }

    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
bool vis[N];

void dijkstra(int s)
{
    q.push(mp(0,-s));
    d[s]=0;
    while(!q.empty())
    {
        int v=abs(q.top().S);ll dist=q.top().F;
        if(q.top().S>0)
        {
            if(dist>=d[v])
                ans++;
            else
                d[v]=dist;
        }
        q.pop();

        if(dist>d[v] || vis[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
        vis[v]=true;
    }
}

int main()
{
    xlr8;
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        q.push(mp(b,a));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
vector <pair<int,ll>> train;

void dijkstra(int s)
{
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    q.push(mp(0,s));
    while(!q.empty())
    {
        int v=q.top().S;
        ll dist = q.top().F;
        q.pop();
        if(dist>d[v])
            continue;
        if(dist==INF)
            return;
        for(auto edge : adj[v])
        {
            int to = edge.F;
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;
    rep(i,0,m)
    {
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].pb(mp(b,c));
        adj[b].pb(mp(a,c));
    }
    rep(i,0,k)
    {
        int a;ll b;
        cin>>a>>b;
        train.pb(mp(a,b));
    }

    dijkstra(1);

    int ans=0;
    rep(i,0,k)
    {
        if(d[train[i].F]<=train[i].S)
            ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
bool vis[N];

void dijkstra(int s)
{
    q.push(mp(0,-s));
    d[s]=0;
    while(!q.empty())
    {
        int v=abs(q.top().S);ll dist=q.top().F;
        if(q.top().S>0 && dist>=d[v])
            ans++;
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        q.push(mp(b,a));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
map <pair<int,int>,bool> tedge;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;

void dijkstra(int s)
{
    q.push(mp(0,s));
    d[s]=0;
    while(!q.empty())
    {
        int v=abs(q.top().S);ll dist=q.top().F;
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<=d[to])
                if(tedge[mp(v,to)]==1 || tedge[mp(to,v)]==1)
                    ans++,tedge[mp(v,to)]=-1,tedge[mp(to,v)]=-1;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        if(d[a]!=INF)
            ans++;
        d[a]=min(d[a],b);
        tedge[mp(1,a)]=1;
        tedge[mp(a,1)]=1;
    }

    rep(i,1,n+1)
    {
        if(d[i]!=INF)
            q.push(mp(d[i],i));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];

void dijkstra(int s)
{
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    q.push(mp(0,s));
    while(!q.empty())
    {
        int v=q.top().S;
        ll dist = q.top().F;
        q.pop();
        if(dist>d[v])
            continue;
        if(dist==INF)
            return;
        for(auto edge : adj[v])
        {
            int to = edge.F;
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;
    rep(i,0,m)
    {
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].pb(mp(b,c));
        adj[b].pb(mp(a,c));
    }

    dijkstra(1);
    int ans=0;
    rep(i,0,k)
    {
        int a;ll b;cin>>a>>b;
        if(d[a]<=b)
            ans++;
    }

    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
map <pair<int,int>,bool> tedge;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;

void dijkstra(int s)
{
    q.push(mp(0,s));
    d[s]=0;
    while(!q.empty())
    {
        int v=q.top().S;ll dist=q.top().F;
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<=d[to])
                if(tedge[mp(v,to)]==1 || tedge[mp(to,v)]==1)
                    ans++,tedge[mp(v,to)]=-1,tedge[mp(to,v)]=-1;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        if(d[a]!=INF)
            ans++;
        d[a]=min(d[a],b);
        tedge[mp(1,a)]=1;
        tedge[mp(a,1)]=1;
    }

    rep(i,1,n+1)
    {
        if(d[i]!=INF)
            q.push(mp(d[i],i));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
map <pair<int,int>,bool> tedge;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;

void dijkstra(int s)
{
    q.push(mp(0,s));
    d[s]=0;
    while(!q.empty())
    {
        int v=q.top().S;ll dist=q.top().F;
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = edge.F;
            ll len = edge.S;
            if((len+dist)<=d[to])
                if(tedge[mp(v,to)]==1 || tedge[mp(to,v)]==1)
                    ans++,tedge[mp(v,to)]=-1,tedge[mp(to,v)]=-1;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        if(d[a]!=INF)
            ans++;
        d[a]=min(d[a],b);
        tedge[mp(1,a)]=1;
        tedge[mp(a,1)]=1;
    }

    rep(i,1,n+1)
    {
        if(d[i]!=INF)
            q.push(mp(d[i],i));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
bool vis[N];

void dijkstra(int s)
{
    q.push(mp(0,-s));
    d[s]=0;
    while(!q.empty())
    {
        int v=abs(q.top().S);ll dist=q.top().F;
        if(q.top().S>0)
        {
            if(dist>=d[v])
                ans++;
            else
                d[v]=dist;
        }
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
    }
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        q.push(mp(b,a));
    }

    dijkstra(1);
    cout<<ans;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define repb(i,a,b)         for(ll i=a;i>=b;i--)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define tr(c,it)            for(auto const &it : c)
#define xlr8                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sz(c)               (c).size()
#define all(c)              (c).begin(),(c).end()
#define sl(a)               scanf("%lld",&a);
#define TH                  1000
#define F                   first
#define S                   second
#define pi                  3.14159265359
ll INF=1e18+10;

const int N=1e5+2;
vector <pair<int,ll>> adj[N];
ll d[N];
int ans=0;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;

void dijkstra(int s)
{
    q.push(mp(0,-s));
    d[s]=0;
    while(!q.empty())
    {
        int v=abs(q.top().S);ll dist=q.top().F;
        if(q.top().S>0)
        {
            if(dist>=d[v])
                ans++;
            else
                d[v]=dist;
        }
        q.pop();

        if(dist>d[v])
            continue;
        if(dist == INF)
            return;
        for(auto edge : adj[v])
        {
            int to = abs(edge.F);
            ll len = edge.S;
            if((len+dist)<d[to])
            {
                d[to]=dist+len;
                q.push(mp(d[to],-to));
            }
        }
    }
}

int main()
{
    xlr8;
    int n,m,k;
    cin>>n>>m>>k;
    rep(i,0,N)
    d[i]=INF;

    for(int i=0;i<m;i++)
    {
        int a,b;ll c;
        cin>>a>>b>>c;
        adj[a].pb(make_pair(b,c));
        adj[b].pb(make_pair(a,c));
    }

    for(int i=0;i<k;i++)
    {
        int a;ll b;
        cin>>a>>b;
        q.push(mp(b,a));
    }

    dijkstra(1);
    cout<<ans;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
//map <int,ll> mark;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			//cout<<dist[adj[i][j].fi]<<" "<<(d)<<" "<<(adj[i][j].se)<<endl;
			if((dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>=(d+adj[i][j].se)))){
				//if(mark[adj[i][j].fi]==1)
				ans[adj[i][j].fi]=0;
				//cout<<555<<endl;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	/*while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}*/
	int cou=0,z=1;
	while(z<=k){
		ll s,y;
		cin>>s>>y;
		//mark[s]=1;
		if(dist[s]==-1){
			dist[s]=y;
			ans[s]=1;
		}
		else{
			if(dist[s]>y){
				dist[s]=y;
			}
			//cou++;
		}
		z++;
	}
	//cout<<cou<<endl;
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	/*for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}*/
	/*for(int i=1;i<=5;i++){
		for(int j=0;j<adj[i].size();j++){
			cout<<i<<" "<<adj[i][j].fi<<" "<<adj[i][j].se<<endl;
		}
	}*/
	dijk();
	for(int i=2;i<=n;i++){
		if(ans[i]==1)
		cou++;
	}
	cout<<(k-cou);
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
map <int,ll> mark;
map <int,int> used;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				if(mark[adj[i][j].fi]==1)
				ans[i]=1;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}
	dijk();
	int cou=0;
	for(int i=2;i<=n;i++){
		if(ans[i]!=0)
		cou+=ans[i];
	}
	cout<<cou;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
//map <int,ll> mark;
ll n;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	for(int i=2;i<=n;i++){
		if(ans[i]==1){
			q.push(mp(dist[i],i));
		}
	}
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			//cout<<dist[adj[i][j].fi]<<" "<<(d)<<" "<<(adj[i][j].se)<<endl;
			if((dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				//if(mark[adj[i][j].fi]==1)
				ans[adj[i][j].fi]=0;
				//cout<<555<<endl;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
			else if(dist[adj[i][j].fi]==(d+adj[i][j].se))
				ans[adj[i][j].fi]=0;
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int m,k;
	cin>>n>>m>>k;
	map<pll,ll> ma;
	for(int i=1;i<=m;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		if(a==b)
		continue;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	/*while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}*/
	ll cou=0,z=1;
	while(z<=k){
		ll s,y;
		cin>>s>>y;
		//mark[s]=1;
		if(dist[s]==-1){
			dist[s]=y;
			ans[s]=1;
		}
		else{
			if(dist[s]>y){
				dist[s]=y;
			}
			//cou++;
		}
		z++;
	}
	//cout<<cou<<endl;
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	/*for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}*/
	/*for(int i=1;i<=5;i++){
		for(int j=0;j<adj[i].size();j++){
			cout<<i<<" "<<adj[i][j].fi<<" "<<adj[i][j].se<<endl;
		}
	}*/
	dijk();
	for(int i=2;i<=n;i++){
		if(ans[i]==1)
		cou++;
	}
	cout<<(k-cou);
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
map <int,ll> mark;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			//cout<<dist[adj[i][j].fi]<<" "<<(d)<<" "<<(adj[i][j].se)<<endl;
			if((dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>=(d+adj[i][j].se)))){
				if(mark[adj[i][j].fi]==1)
				ans[adj[i][j].fi]=0;
				//cout<<555<<endl;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	/*while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}*/
	int cou=0;
	while(k--){
		ll s,y;
		cin>>s>>y;
		mark[s]=1;
		if(dist[s]==-1){
			dist[s]=y;
			ans[s]=1;
		}
		else{
			if(dist[s]>y){
				dist[s]=y;
			}
			cou++;
		}
	}
	//cout<<cou<<endl;
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	/*for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}*/
	/*for(int i=1;i<=5;i++){
		for(int j=0;j<adj[i].size();j++){
			cout<<i<<" "<<adj[i][j].fi<<" "<<adj[i][j].se<<endl;
		}
	}*/
	dijk();
	for(int i=2;i<=n;i++){
		if(ans[i]==0 && mark[i]==1)
		cou++;
	}
	cout<<cou;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	dijk();
	ll ans=0;
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(y>=dist[s] && dist[s]!=-1)
		ans++;
	}
	cout<<ans;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++){
		int x,y,w;
		cin>>x>>y>>w;
		adj[x].pb(mp(y,w));
		adj[y].pb(mp(x,w));
	}
	dijk();
	ll ans=0;
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(y>=dist[s] && dist[s]!=-1)
		ans++;
	}
	cout<<ans;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
//map <int,ll> mark;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			//cout<<dist[adj[i][j].fi]<<" "<<(d)<<" "<<(adj[i][j].se)<<endl;
			if((dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				//if(mark[adj[i][j].fi]==1)
				ans[adj[i][j].fi]=0;
				//cout<<555<<endl;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
			else if(dist[adj[i][j].fi]==(d+adj[i][j].se))
				ans[adj[i][j].fi]=0;
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pll,ll> ma;
	for(int i=1;i<=m;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	/*while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}*/
	ll cou=0,z=1;
	while(z<=k){
		ll s,y;
		cin>>s>>y;
		//mark[s]=1;
		if(dist[s]==-1){
			dist[s]=y;
			ans[s]=1;
		}
		else{
			if(dist[s]>y){
				dist[s]=y;
			}
			//cou++;
		}
		z++;
	}
	//cout<<cou<<endl;
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	/*for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}*/
	/*for(int i=1;i<=5;i++){
		for(int j=0;j<adj[i].size();j++){
			cout<<i<<" "<<adj[i][j].fi<<" "<<adj[i][j].se<<endl;
		}
	}*/
	dijk();
	for(int i=2;i<=n;i++){
		if(ans[i]==1)
		cou++;
	}
	cout<<(k-cou);
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
map <int,ll> mark;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		if(dist[i]!=mark[i] && mark[i]!=0)
		ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=y;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	dijk();
	int cou=0;
	for(int i=2;i<=n;i++){
		if(ans[i]!=0)
		cou+=ans[i];
	}
	cout<<cou;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
map <int,ll> mark;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		if(dist[i]!=mark[i] && mark[i]!=0)
		ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=y;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	dijk();
	int cou=0;
	for(int i=2;i<=n;i++){
		if(ans[i]!=0)
		cou+=ans[i];
	}
	cout<<cou;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++){
		int x,y,w;
		cin>>x>>y>>w;
		adj[x].pb(mp(y,w));
		adj[y].pb(mp(x,w));
	}
	dijk();
	ll ans=0;
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(y>=dist[s])
		ans++;
	}
	cout<<ans;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			if(vis[adj[i][j].fi]==0 && (dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m,k;
	cin>>n>>m>>k;
	map<pii,int> ma;
	for(int i=1;i<=m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	dijk();
	ll ans=0;
	while(k--){
		ll s,y;
		cin>>s>>y;
		if(y>=dist[s] && dist[s]!=-1)
		ans++;
	}
	cout<<ans;
	return 0;
}


// (^_^) (^_^) (^_^) (^_^)
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define all(x) (x).begin(),(x).end()
#define tr(c,it) for(auto it=(c).begin();it!=(c).end();it++)
#define pre(c,x) ((c).find(x) != (c).end())
#define cpre(c,x) (find(all(c),x) != (c).end())
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define prq priority_queue< pll,vector <pll>,greater<pll> >
vector < pll > adj[100001];
vector <ll> dist(100001,-1);
vi vis(100001,0);
vi ans(100001,0);
//map <int,ll> mark;
ll n;
void dijk(){
	dist[1]=0;
	prq q;
	q.push(mp(0,1));
	for(int i=2;i<=n;i++){
		if(ans[i]==1){
			q.push(mp(dist[i],i));
		}
	}
	while(!q.empty()){
		pll p=q.top();
		ll i=p.se,d=p.fi;
		q.pop();
		if(vis[i]==1)
		continue;
		//if(dist[i]!=mark[i] && mark[i]!=0)
		//ans[i]=1;
		vis[i]=1;
		for(int j=0;j<adj[i].size();j++){
			//cout<<dist[adj[i][j].fi]<<" "<<(d)<<" "<<(adj[i][j].se)<<endl;
			if((dist[adj[i][j].fi]==-1 || (dist[adj[i][j].fi]>(d+adj[i][j].se)))){
				//if(mark[adj[i][j].fi]==1)
				ans[adj[i][j].fi]=0;
				//cout<<555<<endl;
				dist[adj[i][j].fi]=d+adj[i][j].se;
				q.push(mp(dist[adj[i][j].fi],adj[i][j].fi));
			}
			else if(dist[adj[i][j].fi]==(d+adj[i][j].se))
				ans[adj[i][j].fi]=0;
		}
	}
}
int main(){
	io;
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int m,k;
	cin>>n>>m>>k;
	map<pll,ll> ma;
	for(int i=1;i<=m;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		if(a==b)
		continue;
		if(!pre(ma,mp(a,b))){
			ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
		if(ma[mp(a,b)]>c){
		    ma[mp(a,b)]=c;
			ma[mp(b,a)]=c;
		}
	}
	/*while(k--){
		ll s,y;
		cin>>s>>y;
		if(!pre(ma,mp(1,s))){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			mark[s]=1;
		}
		else if(ma[mp(1,s)]>y){
			ma[mp(1,s)]=y;
			ma[mp(s,1)]=y;
			if(mark[s]!=0)
			ans[s]++;
		}
		else{
			ans[s]++;
		}
	}*/
	ll cou=0,z=1;
	while(z<=k){
		ll s,y;
		cin>>s>>y;
		//mark[s]=1;
		if(dist[s]==-1){
			dist[s]=y;
			ans[s]=1;
		}
		else{
			if(dist[s]>y){
				dist[s]=y;
			}
			//cou++;
		}
		z++;
	}
	//cout<<cou<<endl;
	tr(ma,it){
		adj[(it->fi).fi].pb(mp((it->fi).se,it->se));
	}
	/*for(int i=2;i<=n;i++){
		if(mark[i]==1)
		dist[i]=ma[mp(1,i)];
	}*/
	/*for(int i=1;i<=5;i++){
		for(int j=0;j<adj[i].size();j++){
			cout<<i<<" "<<adj[i][j].fi<<" "<<adj[i][j].se<<endl;
		}
	}*/
	dijk();
	for(int i=2;i<=n;i++){
		if(ans[i]==1)
		cou++;
	}
	cout<<(k-cou);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int> test;
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=1;i<=k;i++){
	 if(test[i]>0)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<d[ed.first]){
		      if(test[ed.first]>0)test[ed.first]=0;
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.assign(k+1,0);
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		adj[y].push_back({x,r});
	}

	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=y;
	}
	dijkstra(1);
	int ans=0;
	for(int i=1;i<=k;i++){
	 if(test[i]>0)ans++;
	}
	cout<<k-ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int> test;
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=1;i<=k;i++){
	  pq.push({d[test[i]],test[i]});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<d[ed.first]){
		      if(test[ed.first]>0)test[ed.first]=0;
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.assign(n+1,0);
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		adj[y].push_back({x,r});
	}

	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		d[x]=min((int)d[x],y);
		test[x]=y;
	}
	dijkstra(1);
	int ans=0;
	for(int i=1;i<=k;i++){
	 if(test[i]>0)ans++;
	}
	cout<<k-ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(100020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		//adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(10020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		      d[ed.first]=d[u]+ed.second;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		//adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(100020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		      d[ed.first]=d[u]+ed.second;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		//adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(10020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(10020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=1;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=y;;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(100020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		long long dis=pq.top().first;
		pq.pop();
		if(dis!=d[u])continue;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		//adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
set<int > test;
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(set<int> ::iterator it=test.begin();it!=test.end();it++){
	  pq.push({d[*it],*it});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      if(test.find(ed.first)!=test.end())test.erase(ed.first);
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test.insert(x);
	}
	int ans=test.size()+cnt;
	dijkstra(1);

	int ans2=test.size();
	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(10020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=1;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(100020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	//pq.push({d[v],v});
	for(int i=1;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		long long dis=pq.top().first;
		pq.pop();
		if(dis!=d[u])continue;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//const int inf=1e9;
vector<vector<pair<int,int> > > adj;
vector<bool> mark;
vector<int> p;
vector<pair<int,int> >  train;
vector<long long int> d;
vector<int > test(10020,0);
int n,m,k;

void dijkstra(int v){
	d[v]=0;
	priority_queue<pair<long long,int>,vector<pair<long long ,int> >,greater<pair<long long ,int> > > pq;
	pq.push({d[v],v});
	for(int i=2;i<=n;i++){
	 if(d[i]!=LLONG_MAX)
	  pq.push({d[i],i});
	}
	int u;
	while(!pq.empty()){
		u=pq.top().second;
		pq.pop();
		if(mark[u])continue;
		mark[u]=true;
		for(auto ed:adj[u]){
		   if(d[u]+ed.second<=d[ed.first]){
		      test[ed.first]=0;
		   }
		   if(d[u]+ed.second<d[ed.first]){
		      d[ed.first]=d[u]+ed.second;
		      p[ed.first]=u;
		      pq.push({d[ed.first],ed.first});
		   }
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m>>k;
	adj.resize(n+1);
	d.assign(n+1,LLONG_MAX);
	p.assign(n+1,-1);
	mark.assign(n+1,false);
	test.clear();
	for(int i=0;i<m;i++){
		int x,y,r;
		cin>>x>>y>>r;
		adj[x].push_back({y,r});
		adj[y].push_back({x,r});
	}
	int cnt=0;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		//if(test.find(x)!=test.end())cnt++;
		d[x]=(d[x]>y)?y:d[x];
		test[x]=1;
	}
	int ans=k;
	dijkstra(1);

	int ans2=0;
	for(int i=1;i<=n;i++)
	if(test[i])ans2++;

	cout<<ans-ans2;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n);
    map<pair<int,int>, pair<int,int> > mp;

    auto get = [] (int a,int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(!mp.count(get(x,y)))
            mp[get(x,y)] = {w,0};
        else mp[get(x,y)] = min({w,0}, mp[get(x,y)]);
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(!mp.count(get(0,x)))
            mp[get(0,x)] = {y,i + 1};
        else mp[get(x,0)] = min(make_pair(y, i + 1), mp[get(x,0)]);
    }

    for (auto p: mp) {
        int x = p.first.first;
        int y = p.first.second;
        int w = p.second.first;
        int id = p.second.second;
        G[x].push_back({y,w,id});
        G[y].push_back({x,w,id});
    }

    priority_queue<pair<long long, int> > q;
    q.push({0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        w = -q.top().first;
        u = q.top().second;
        q.pop();
        if(dis[u] != -w) continue;
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(st[u], type2);
                q.push({-dis[v], v});
            } else if(dis[u] + w2 == dis[v] and max(type2, st[u]) == 0) {
                st[v] = max(type2, st[u]);
                q.push({-dis[v], v});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<set<tuple<int,int,int> > > G(n);
    map<pair<int,int>, int> mp;
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);

    auto get = [] (int a, int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };
    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(mp.count(get(x,y))) {
            if(mp[get(x,y)] > w) {
                G[x].erase({y, mp[get(x,y)], 0});
                G[y].erase({x, mp[get(x,y)], 0});
                G[x].insert({y, w, 0});
                G[y].insert({x, w, 0});
                mp[get(x,y)] = w;
            }
        } else {
            G[x].insert({y, w, 0});
            G[y].insert({x, w, 0});
            mp[get(x,y)] = w;
        }
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(mp.count(get(1,x))) {
            if(mp[get(x,y)] > w) {
                G[x].erase({y, mp[get(x,y)], 0});
                G[y].erase({x, mp[get(x,y)], 0});
                G[0].insert({x, y, i + 1});
                G[x].insert({0, y, i + 1});
                mp[get(x,y)] = w;
            }
        } else {
            mp[get(x,y)] = y;
            G[0].insert({x, y, i + 1});
            G[x].insert({0, y, i + 1});
        }
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;

    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = (int)1e5 + 100;

struct edge {
    int to, w, train;
};

vector< edge > g[N];
long long d[N];
int p[N];
int by[N];

int n, m, k;
int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i= 0 ; i < m ; i ++) {
        int u, v, c;
        scanf("%d%d%d", &u, &v, &c);
        edge e = {v, c, 0};
        g[u].push_back(e);
        e.to = u;
        g[v].push_back(e);
    }
    for (int i = 0 ; i < k ; i ++) {
        int to, c;
        scanf("%d%d", &to, &c);
        edge e = {to, c, 1};
        g[1].push_back(e);
    }
    priority_queue<pair<long long , int > > q;
    d[1] = 0;
    for (int i = 2 ; i <= n ; i ++)
        d[i] = 1ll << 60;
    q.push(make_pair(-d[1], 1));

    while (!q.empty()) {
        long long curd = -q.top().first;
        int curv = q.top().second;
        q.pop();
        if (d[curv] != curd) continue;
        for (int i = 0 ; i < g[curv].size(); i ++) {
            int to = g[curv][i].to, w = g[curv][i].w;
            if (d[curv] + w < d[to] || (d[curv] + w == d[to] && by[to] == 1
                                        && g[curv][i].train == 0)) {
                d[to] = d[curv] + w;
                p[to] = curv;
                by[to] = g[curv][i].train;
                q.push(make_pair(-d[to], to));
            }
        }
    }
    int res = 0;
    for (int i = 2 ; i <= n ; i ++) {
        if (p[i] == 1 && by[i] == 1)
            res ++;
    }
    cout << k - res << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        G[x].push_back({y, w, 0});
        G[y].push_back({x, w, 0});
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        G[0].push_back({x, y, i + 1});
        G[x].push_back({0, y, i + 1});
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();

        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and type == 0) {
                st[v] = 0;
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<set<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        G[x].insert({y, w, 0});
        G[y].insert({x, w, 0});
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        G[0].insert({x, y, i + 1});
        G[x].insert({0, y, i + 1});
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);
    map<pair<int,int>, pair<int,int> > mp;

    auto get = [] (int a,int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(!mp.count(get(x,y)))
            mp[get(x,y)] = {w,0};
        else mp[get(x,y)] = min({w,0}, mp[get(x,y)]);
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(!mp.count(get(0,x)))
            mp[get(0,x)] = {y,i + 1};
        else mp[get(x,0)] = min(make_pair(y, i + 1), mp[get(x,0)]);
    }

    for (auto p: mp) {
        int x = p.first.first;
        int y = p.first.second;
        int w = p.second.first;
        int id = p.second.second;
        G[x].push_back({y,w,id});
        G[y].push_back({x,w,id});
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        if(dis[u] != w) continue;
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);
    map<pair<int,int>, pair<int,int> > mp;

    auto get = [] (int a,int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(!mp.count(get(x,y)))
            mp[get(x,y)] = {w,0};
        else mp[get(x,y)] = min({w,0}, mp[get(x,y)]);
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(!mp.count(get(0,x)))
            mp[get(0,x)] = {y,i + 1};
        else mp[get(x,0)] = min(make_pair(y, i + 1), mp[get(x,0)]);
    }

    for (auto p: mp) {
        int x = p.first.first;
        int y = p.first.second;
        int w = p.second.first;
        int id = p.second.second;
        G[x].push_back({y,w,id});
        G[y].push_back({x,w,id});
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        if(dis[u] < w) continue;
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);
    map<pair<int,int>, pair<int,int> > mp;

    auto get = [] (int a,int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(!mp.count(get(x,y)))
            mp[get(x,y)] = {w,0};
        else mp[get(x,y)] = min({w,0}, mp[get(x,y)]);
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(!mp.count(get(0,x)))
            mp[get(0,x)] = {y,i + 1};
        else mp[get(x,0)] = min(make_pair(y, i + 1), mp[get(x,0)]);
    }

    for (auto p: mp) {
        int x = p.first.first;
        int y = p.first.second;
        int w = p.second.first;
        int id = p.second.second;
        G[x].push_back({y,w,id});
        G[y].push_back({x,w,id});
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        if(dis[u] != -w) continue;
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<set<tuple<int,int,int> > > G(n);
    map<pair<int,int>, pair<int,int> > mp;
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);

    auto get = [] (int a, int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };
    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(mp.count(get(x,y))) {
            if(mp[get(x,y)].first > w) {
                G[x].erase({y, mp[get(x,y)].first, 0});
                G[y].erase({x, mp[get(x,y)].first, 0});
                G[x].insert({y, w, 0});
                G[y].insert({x, w, 0});
                mp[get(x,y)] = {w, 0};
            }
        } else {
            G[x].insert({y, w, 0});
            G[y].insert({x, w, 0});
            mp[get(x,y)] = {w, 0};
        }
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(mp.count(get(1,x))) {
            if(mp[get(x,y)].first > y) {
                G[x].erase({y, mp[get(x,y)].first, mp[get(x,y)].second});
                G[y].erase({x, mp[get(x,y)].first, mp[get(x,y)].second});
                G[0].insert({x, y, i + 1});
                G[x].insert({0, y, i + 1});
                mp[get(x,y)] = {y, i + 1};
            }
        } else {
            mp[get(x,y)] = {y, i + 1};
            G[0].insert({x, y, i + 1});
            G[x].insert({0, y, i + 1});
        }
    }

    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;

    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    ios::sync_with_stdio(false); cin.tie(0);
    int n,m,k,x,y,u,v, type, type2;
    long long w,w2;

    scanf("%d %d %d", &n, &m, &k);

    vector<vector<tuple<int,int,int> > > G(n);
    vector<long long> dis(n, LLONG_MAX);
    vector<int> st(n, INT_MAX);
    map<pair<int,int>, pair<int,int> > mp;

    auto get = [] (int a,int b) -> pair<int,int> {
        return {min(a,b), max(a,b)};
    };

    for (int i = 0; i < m; ++i) {
        scanf("%d %d %lld", &x, &y, &w);
        x--,y--;
        if(!mp.count(get(x,y)))
            mp[get(x,y)] = {w,0};
        else mp[get(x,y)] = min({w,0}, mp[get(x,y)]);
    }

    for (int i = 0; i < k; ++i) {
        scanf("%d %d", &x, &y);
        x--;
        if(!mp.count(get(0,x)))
            mp[get(0,x)] = {y,i + 1};
        else mp[get(x,0)] = min(make_pair(y, i + 1), mp[get(x,0)]);
    }

    for (auto p: mp) {
        int x = p.first.first;
        int y = p.first.second;
        int w = p.second.first;
        int id = p.second.second;
        G[x].push_back({y,w,id});
        G[y].push_back({x,w,id});
    }
    priority_queue<tuple<long long, int, int> > q;
    q.push({0,0,0});
    dis[0] = 0;
    st[0] = 0;
    while(!q.empty()) {
        tie(w, u, type) = q.top();
        q.pop();
        for (auto p: G[u]) {
            tie(v, w2, type2) = p;
            if(dis[u] + w2 < dis[v]) {
                dis[v] = dis[u] + w2;
                st[v] = max(type, type2);
                q.push({-dis[v], v, st[v]});
            } else if(dis[u] + w2 == dis[v] and max(type2, type) == 0) {
                st[v] = max(type2, type);
                q.push({-dis[v], v, st[v]});
            }
        }
    }

    set<int> s;
    for (int i = 0; i < n; ++i)  {
        if(st[i]) s.insert(st[i]);
    }
    cout << k - s.size() << "\n";

    return 0;
}