Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		t, _ := strconv.Atoi(scanner.Text())
		if t == 0 {
			break
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		for i  := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			s, _ := strconv.Atoi(buf[0])
			f, _ := strconv.Atoi(buf[1])
			t -= (f-s)
		}
		if t <= 0 {
			fmt.Println("OK")
		} else {
			fmt.Println(t)
		}
	}
}

C++: #include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int t;

void solve() {
    int n;
    int s,f;
    int sum = 0;
    cin>>n;
    rep(i,n) {
        cin>>s>>f;
        sum += f-s;
    }

    if(t<=sum) {
        cout<<"OK"<<endl;
    }
    else {
        cout<<t-sum<<endl;
    }
}

int main() {
    while(cin>>t) {
        if(t==0) break;
        solve();
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int d, n, s, t, sum;
int main() {
  
  while(cin>>d>>n, d) {sum=0;
    for(int i=0; i<n; i++) {
      cin >> s >> t;
      sum += t-s;
    }
    if(sum<d) cout << sum-d << endl;
    else cout << "OK" << endl;
  }
  
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define GRESORT(v) sort(v.begin(),v.end(),greater<int>())
#define REVERSE(v) reverse(v.begin(),v.end())
#define overlap(v) v.erase(unique(v.begin(),v.end()),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4??????
//int dy[]={0, 0, 1, -1};
//int dx[]={1, -1, 0, 0};

//8??????
int dy[]={0,0,1,-1,1,1,-1,-1};
int dx[]={1,-1,0,0,1,-1,1,-1};

ll mod = (ll)1e9+7;
int a,b,c,d;

void solve() {
    while(cin >> a){
        if(a == 0) break;
        int sum = 0;
        cin >> b;
        rep(j,b){
            cin >> c >> d;
            sum += d - c;
        }
        if(sum >= a) cout << "OK" << endl;
        else cout << a - sum << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    solve();

    return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n,t,s,f,total=0;
	
	while(cin>>t){
		if(t==0)break;
		
		total=0;
		
		cin>>n;
		
		for(int i=0;i<n;i++){
			
			cin>>s>>f;
			total+=f-s;
			
		}
		
		if(total>=t){
			cout<<"OK"<<endl;
		}else{
			cout<<t-total<<endl;
		}
		
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int t,n,s,f;
	int sum;
	
	while(scanf("%d",&t)){
		if(t==0)
		break;
		scanf("%d",&n);
		sum=0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(sum>=t)
		printf("OK\n");
		else
		printf("%d\n",t-sum);
	}
}

C++: #include<stdio.h>
int main(void)
{
    int a,b,c[15],d[15],i,f;
	scanf("%d",&a);
	while(a!=0){
	    f=0;
	    scanf("%d",&b);
	    for(i=0;i<b;i++){
		    scanf("%d %d",&c[i],&d[i]);
		}
		for(i=0;i<b;i++){
		    f=f+(d[i]-c[i]);
		}
		if(f>=a) printf("OK\n");
		else if(f<a) printf("%d\n",a-f);
		scanf("%d",&a);
	}
	return 0;
}

C++: #include<stdio.h>
int main(){
  int t,n;
  int sum=0;
  int i,s,e;
  while(1){
    scanf("%d",&t);
    if(t == 0){
      break;
    }
    scanf("%d",&n);
    for(i = 0;i < n;i++){
      scanf("%d %d",&s,&e);
      sum+=e-s;
    }
    if(t<=sum){
      printf("OK\n");
    }
    else{
      printf("%d\n",t-sum);
    }
    sum = 0;
  }
  return(0);
}

C++: #include<stdio.h>
int main(void) 
{
	int t, n, s, f,a,b,c=0,d;
	scanf("%d", &t);
	scanf("%d", &n);
	for (a = 1;a <= n;a++)
	{
		scanf("%d %d", &s, &f);
		b = f - s;
		c = c + b;
	}
	d = t - c;
	if (d > 0)
	{
		printf("%d\n",d);
	}
	else
	{
		printf("OK!!\n");
	}
	return 0;
}

C++: #include<stdio.h>
int main (void)
{
	int t,n,s,f,i,t1,t2,t3;
		scanf("%d",&t);
		scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d %d",&s,&f);
		t1=f-s;
		t2+=t1;
	
	}
	if(t2>t){
		printf("OK\n");
	}
	else{
		t3=t-t2;
		printf("%d\n",t3);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,t,s,f,sum;
int main(){
  while(cin>>t&&t){
    cin>>n;
    sum=0;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      sum+=(f-s);
    }
    if(sum>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-sum<<endl;
    }
  }
  return 0;
}

C++: include <iostream>
using namespace std;
int d, n, s, t, sum;
int main() {
  
  while(cin>>d>>n, d) {
    for(int i=0; i<n; i++) {
      cin >> s >> t;
      sum += t-s;
    }
    if(sum<d) cout << sum-d << endl;
    else cout << "OK" << endl;
  }
  
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
using namespace std;
 
const int MAX= 10000100;
 
int main(void){
  int t,n;
  while(cin>>t,t){
    int ans = 0;
    cin>>n;
    for(int i = 0 ; i < n ; i ++){
      int s,e;
      cin>>s>>e;
      ans+=e-s;
    }
    cout<<(ans>t?"OK":t-ans)<<endl;
   }
}

C++: using System;

namespace a{
    class Program
{
    static void Main(string[] args)
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }
}
}

C++: #include <iostream>
using namespace std;
int main (){
       int a;
       while(cin>>a){
            if(a==0)break;
            int N;
            cin>>N;
            int ans=0;
            for(int i=0;i<N;i++){
                      int c,d;
                      cin>>c>>d;
                       ans=ans+(d-c);
               }
                       if(ans>=a){
                              cout<<"OK"<<endl;
                        }
                        else{   cout<<a-ans<<endl;
                      }   
                }
         return 0;
  }

C++: #include<stdio.h>
int main(void)
{
    int t,n,i,s,f,p,q;
	scanf("%d %d",&t,&n);
	for(i=0;i<n;i++){
	    scanf("%d %d",&s,&f);
		p=f-s;
		q=q+p;
	}
	printf("%d\n",q);
	return 0;
}

C++: #include<stdio.h>

int main(){

int G,N;
while(1){
scanf("%d",&G);if(G==0)break;

scanf("%d",&N);
int s,f;
for(int i=0;i<N;i++)
{
scanf("%d %d",&s,&f);
f-=s;
G-=f;
//if(G<=0)break;
}
if(G<=0)printf("OK\n");
else printf("%d\n",G);
}
return 0;
}