There is a famous riddle-joke for children:
Three turtles are crawling along a road. The first turtle says: "There are two turtles ahead of me." The second turtle says: "There are two turtles behind me." The third turtle says: "There are two turtles ahead of me and two turtles behind me." How can this be?
The answer is: the third turtle is lying!
In this problem, n turtles are crawling along a road. Several turtles may crawl together in a group at the same position, so that turtles in the same group see none of their group members either ahead or behind them. Each turtle makes a statement of the form: "There are ai turtles ahead of me and bi turtles behind me." Find the minimum possible number of turtles that are lying.
Formally, turtle i has a coordinate xi, and different turtles may share the same coordinate. Turtle i tells the truth if and only if the number of turtles j with xj>xi is exactly ai and the number of turtles j with xj<xi is exactly bi; otherwise turtle i is lying. You may choose the coordinates freely, and you must report the minimum number of turtles that must be lying, taken over all arrangements (equivalently, n minus the maximum number that can simultaneously tell the truth).
The first line contains an integer n (1≤n≤1000). Each of the next n lines contains two integers ai and bi (0≤ai,bi≤1000) describing the statement of turtle i for i from 1 to n.
Print a single integer m: the minimum number of turtles that must be lying.