AmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are $n$ cities in Italy indexed from $1$ to $n$ and $m$ directed roads indexed from $1$ to $m$. Initially, Keshi is located in the city $1$ and wants to go to AmShZ's house in the city $n$. Since Keshi doesn't know the map of Italy, AmShZ helps him to see each other as soon as possible.

In the beginning of each day, AmShZ can send one of the following two messages to Keshi:

AmShZ sends the index of one road to Keshi as a blocked road. Then Keshi will understand that he should never use that road and he will remain in his current city for the day.

AmShZ tells Keshi to move. Then, Keshi will randomly choose one of the cities reachable from his current city and move there. (city $B$ is reachable from city $A$ if there's an out-going road from city $A$ to city $B$ which hasn't become blocked yet). If there are no such cities, Keshi will remain in his current city.

Note that AmShZ always knows Keshi's current location.

AmShZ and Keshi want to find the smallest possible integer $d$ for which they can make sure that they will see each other after at most $d$ days. Help them find $d$.


-----Input-----

The first line of the input contains two integers $n$ and $m$ $(2 \le n \le 2 \cdot 10^5, 1 \le m \le 2 \cdot 10^5)$  — the number of cities and roads correspondingly.

The $i$-th line of the following $m$ lines contains two integers $v_i$ and $u_i$ $(1 \le v_i , u_i \le n,v_i \neq u_i)$, denoting a directed road going from city $v_i$ to city $u_i$.

It is guaranteed that there is at least one route from city $1$ to city $n$. Note that there may be more than one road between a pair of cities in each direction.


-----Output-----

Output the smallest possible integer $d$ to make sure that AmShZ and Keshi will see each other after at most $d$ days.


-----Examples-----

Input
2 1
1 2
Output
1
Input
4 4
1 2
1 4
2 4
1 4
Output
2
Input
5 7
1 2
2 3
3 5
1 4
4 3
4 5
3 1
Output
4


-----Note-----

In the first sample, it's enough for AmShZ to send the second type of message.

In the second sample, on the first day, AmShZ blocks the first road. So the only reachable city from city $1$ will be city $4$. Hence on the second day, AmShZ can tell Keshi to move and Keshi will arrive at AmShZ's house.

It's also possible for AmShZ to tell Keshi to move for two days.

Difficulty: HARD

Solutions:
from heapq import heappop, heappush
import math
(n, m) = map(int, input().split())
lst = [[] for i in range(n + 1)]
paths = [0] * (n + 1)
for i in range(m):
	(a, b) = map(int, input().split())
	lst[b].append(a)
	paths[a] += 1
arr = []
arr.append((0, n))
days = [math.inf] * (n + 1)
days[n] = 0
mark = [False] * (n + 1)
while arr:
	ele = heappop(arr)
	if mark[ele[1]]:
		continue
	mark[ele[1]] = True
	for i in lst[ele[1]]:
		if ele[0] + paths[i] < days[i]:
			days[i] = ele[0] + paths[i]
			heappush(arr, (days[i], i))
		paths[i] -= 1
print(days[1])


import heapq as h
INF = 1001001001
(N, M) = map(int, input().split())
G = [[] for _ in range(N)]
d = [0] * N
for _ in range(M):
	(U, V) = map(int, input().split())
	G[V - 1].append(U - 1)
	d[U - 1] += 1
dists = [INF] * N
dists[N - 1] = 0
queue = [(0, N - 1)]
while queue:
	(dist, V) = h.heappop(queue)
	if dists[V] < dist:
		continue
	for v in G[V]:
		if dist + d[v] < dists[v]:
			dists[v] = dist + d[v]
			h.heappush(queue, (dist + d[v], v))
		d[v] -= 1
print(dists[0])


import heapq
input = __import__('sys').stdin.readline
(n, m) = map(int, input().split())
deg = [0] * n
rev_adj = [[] for _ in range(n)]
for _ in range(m):
	(u, v) = map(lambda x: int(x) - 1, input().split())
	deg[u] += 1
	rev_adj[v].append(u)
dist = [10 ** 6] * n
dist[-1] = 0
queue = []
heapq.heappush(queue, (0, n - 1))
while len(queue) > 0:
	(d, u) = heapq.heappop(queue)
	if d > dist[u]:
		continue
	for v in rev_adj[u]:
		if dist[v] > dist[u] + deg[v]:
			dist[v] = dist[u] + deg[v]
			heapq.heappush(queue, (dist[v], v))
		deg[v] -= 1
print(dist[0])