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++: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

int main(){
	int duration;
	while(~scanf("%d",&duration)){
		if(duration == 0) break;
		int n;
		scanf("%d",&n);

		int sum = 0;
		for(int i=0;i<n;i++){
			int a,b;
			scanf("%d %d",&a,&b);
			sum += b - a;
		}

		if(sum >= duration) printf("OK\n"); 
		else printf("%d\n",duration - 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+=d-c;
               }
                       if(ans>a){
                              cout<<"OK"<<endl;
                        }
                        else{   cout<<"NO"<<endl;
                      }   
                }
         return 0;
  }

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n, n){
		int m, sum = 0;
		cin >> m;
		rep(i, m){
			int A, B;
			cin >> A >> B;
			sum += abs(A-B);
		}
		if(sum >= n){
			cout << "OK" << endl;
		}else{
			cout << abs(n-sum) << endl;
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,t;
  while(1){
    cin>>t;
    if(t==0)break;
    cin>>n;
    int sum=0;
    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()
{
    int t, n;
    int s, f;
    int sum;

    while (cin >> t, t != 0) {
        sum = 0;
        
        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>
int main() {
    int t, n, s, e, sum;
    for (; ;) {
        scanf("%d", &t);
        if (t == 0) break;
        sum = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
            scanf("%d %d", &s, &e);
            sum+= e-s;
        }
        (sum >= t) ? printf("OK\n") : printf("%d\n", t-sum);
    }
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
    for(;;){
		int t,n;
		cin >>t;
		if(t==0)return 0;
		cin >> n;
		int time=0;
		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			time+=(y-x);
		}
		if(time>=t)printf("OK\n");
		else printf("%d\n",t-time);
	}
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int t,n,i,s,f,sum;
	while(1){
		sum=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(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);
		}
	}
	return 0;
}

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

int main(){
  int a,n,t1,t2;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> a;
    for(int i=0;i<a;i++){
      cin >> t1 >> t2;
      n -= t2 - t1;
      if(n <= 0){
	cout << "OK" << endl;
	break;
      }
    }
    if(n > 0){
      cout << n << endl;
    }
  }
}