P11126 [AOJ] Animal Companion in Maze
普及
题目描述

Example

Input

2 1
1 2 2

Output

1

输入格式

见题面

输出格式

见题面

样例输入
2 1 1 2 2
样例输出
1