1677:缩进对齐

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:3 解决:2

题目描述

有一段代码,共有 lns="http://www.w3.org/1998/Math/MathML"> 行,起初第 lns="http://www.w3.org/1998/Math/MathML"> 行代码的开头有 lns="http://www.w3.org/1998/Math/MathML"> 个空格,根据代码的逻辑关系,小爱希望第 lns="http://www.w3.org/1998/Math/MathML"> 行开头调整成为 lns="http://www.w3.org/1998/Math/MathML"> 个空格。

小爱的文本编辑器有一个功能,它可以选中任意多行连续的代码,通过一步操作就可以在这些行的开头增加或删除一个空格。注意,若选择删除一个行首空格,必须保证选中的每一行行首都至少有一个空格,不然文本编辑器会误删其他字符,程序就要出错了。

请问最少需要多少步,才能让这段代码的缩进调整成指定的样子?

输入

第一行:单个整数 lns="http://www.w3.org/1998/Math/MathML">
第二行到第 lns="http://www.w3.org/1998/Math/MathML">+1 行:每行两个整数,表示 lns="http://www.w3.org/1998/Math/MathML"> 与 lns="http://www.w3.org/1998/Math/MathML">


  • 对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">1100,000
  • lns="http://www.w3.org/1998/Math/MathML">0,10,000


输出

单个整数:表示最少步数。

样例输入-1 复制

4
1 2
2 2
2 2
1 2

样例输出-1 复制

2