import math
num,k = list(map(int, input().split(' ')))
count = 0
for i in (range(num)):
rang = list(map(int, input().split(' ')))
count += rang[1]-rang[0]+1
count = k* math.ceil(count/k) - count
print(count)
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<cmath> //float result = pow(b,p) //trunc(10.25)=10 // floor(10.55)=10 // ceil(10.55)=11 //round(10.1)=10 , round(10.55)=11
#include <unordered_map> // unordered_map<int,int>mp;
using namespace std;
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
// -842150451
// a=97 , z= 122 , A=65 ,Z=90
#include<set>
int main() {
//extern int arr [5] ;
//fast
int before=0 , after =0 ;
int n, k; cin >> n >> k;
for (int i = 0;i<n;i++) {
int l; cin >> l;
int r; cin >> r;
before += 1 + r - l;
}
for (int i = 0; true; i++) {
if ((after+before) % k == 0) {
break;
}
after++;
}
cout << after << endl;
}
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |