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<iostream>
using namespace std;
int main()
{
	int m,n,s,e;
	int sum;
	int i;
	while(cin >> m,m)
	{
		sum=0;
		cin >> n;
		for(i=0;i<n;i++)
		{
			cin >> s >> e;
			sum+= e-s;
		}
		if(sum>=m) cout << "OK\n";
		else cout << m-sum << endl;
	}
	return 0;
}

C++: #include <cstdio>

int t, n, s, f, sum;

int main(){
    while(scanf("%d", &t) != EOF){
        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("%d\n", t - sum);
        else printf("OK\n");
    }


    return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

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

C++: #include <iostream>
using namespace std;
int main(void){
    int t,n;
    int s[22], f[22];
 
    while(true){
        cin >> t;
        if(t == 0) {
            break;
        }
 
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> s[i] >> f[i];
        }
         
        int time = 0;
        for(int i = 0; i < n; i++){
            time += f[i] - s[i];
        }
        if(time >= t) 
            cout << "OK" << endl;
        else{
            cout << t - time << endl;
        }
    }
}

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

C++: #include <iostream>
using namespace std;
int main (void)
{
	while(true)
	{
		int n, m, p;
		p = 0;
		cin >> n;
		if(n == 0) 
		{
			break;
		}
		cin >> m;
		while(m > 0)
		{
			int s, q;
			cin >> s >>q;
			p += q-s;
			m--;
		}
		if(p >= n)
		{
			cout << "OK"<< endl;
		}
		else
		{
			cout << n - p;
		}
	}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(void){
    while(1){
        ll t=0,n;cin>>t;
        if(t==0)break;
        cin>>n;
        ll time=0;
        ll s[n],f[n];
        rep(i,0,n){
          ll s,f;
            cin>>s>>f;
            time+=f-s;
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
    
}

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

int ans[100];
int cor;

int main(){
	int T,N;
	int s,t,sum;
	while( cin >> T >> N )
	{
		sum = 0;
		for(int i = 0;i < N;i++){
			cin >> s >> t;
			sum += t-s;
		}
		if( sum < T )
			ans[cor] = T-sum;
		cor++;
	}
	for(int i = 0;i < cor;i++){
		if( ans[i] )
			cout << ans[i] << endl;
		else
			cout << "OK" << endl;
	}
	return 0;
}

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

int main(){
	int t,n,s,e,sum;
	while(cin>>t,t){
		cin>>n;
		sum=0;
		while(n--){
			cin>>s>>e;
			sum+=e-s;
		}
		if(t<=sum)cout<<"OK\n";
		else cout<<t-sum<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int t,n,s,f,sum;
	
	while(1){
		sum = 0;
		cin >> t;
		if(t == 0) break;
		cin >> n;
		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 <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int t; (t = in());) {
		for (int n = in(); n; n--) {
			int s = in();
			t -= in() - s;
		}
		if (t > 0)
			outl(t);
		else
			outl("OK");
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
  int t,n;
  int s,f;
  int sum;

  while(1){
    sum = 0;
    cin>>t;

    if(t == 0){
      break;
    }

    cin>>n;

    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 main(){
	int time,n,start,fin,sum;
	while(cin>>time,time){
		cin>>n;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>start>>fin;
			sum+=fin-start;
		}
		if(sum>=time)cout<<"OK"<<endl;
		else cout<<time-sum<<endl;
	}
}

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

int main() {
  int d, n, s, t, sum;
  
  while(cin>>d>>n) {
    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<stdio.h>
int main(){
  int a,n,b,c,sum;
  while(scanf("%d",&a),a!=0){
    scanf("%d",&n);
    sum = 0;
    for(int i=0;i<n;i++){
      scanf("%d %d",&b,&c);
      sum += c-b;
    }
    if(a <= sum) puts("OK");
    else printf("%d\n",a-sum);
  }
  return (0);
}

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

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

int t,n,s,f,sum;

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