https://www.acmicpc.net/problem/10833
import java.util.*;
import java.lang.String.format
fun main(args: Array<String>) {
val s=Scanner(System.`in`)
var n=s.nextInt()
var sum=0
for(i in 0 until n){
var a=s.nextInt()
var b=s.nextInt()
sum+=b%a
}
print(sum)
}