1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<bits/stdc++.h>

#define luk(n,m) for(int i=n; i<m; ++i)
#define maxn 310
#define pb(n) push_back(n)
#define mp make_pair
#define inf 1000000000
#define mod 1000000007
#define ll long long
#define ff first.first
#define fs first.second


using namespace std;

vector<int>kraw[maxn];
int n,k,mini=inf;
int dp[maxn], czy[maxn];




int licz()
{
	int maxi=0;
	luk(1,n+1)
	{
		int s=(int)kraw[i].size();
		for(int j=0; j<s; ++j)
		{
			if(czy[kraw[i][j]]!=inf)
				dp[kraw[i][j]]=max(dp[kraw[i][j]], dp[i]+1);
		}
		maxi=max(maxi,dp[i]);
	}
	return maxi;
}

void czysc()
{
	luk(1,n+1)
	dp[i]=0;
}


void rob(int x, int a)
{
	if(x==k)
	{
		czysc();
		mini=min(licz(),mini);
		return;
	}
	luk(a,n+1)
	{
		czy[i]=inf;
		rob(x+1,i+1);
		czy[i]=0;
	}
}

int main()
{
	int m,a,b;
	scanf("%d%d%d", &n, &m, &k);
	luk(0,m)
	{
		scanf("%d%d", &a, &b);
		kraw[a].pb(b);
	}
	rob(0,1);
	if(k==n)
	printf("0");
	else
	printf("%d", mini+1);
}