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(void){
    while(true){
        int s,f,S,M=0;
        int t;
        cin >>t;
        int n;
        cin >>n;
        if(t==0)break;
        for(int i=0;i<n;i++){
            cin >>s>>f;
            S=f-s;
            M=M+S;
        }
        if(M>=t){
            cout <<"OK"<<endl;
        }
        else{
            cout <<t-M<<endl;
        }
    }
}

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

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

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

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

C++: #include<iostream>
using namespace std;
int n,t,s,f,sum;
int main(void){
  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 main(void){
int n,t,s,f,sum;
  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>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
using namespace std;

int main(){
	int t,n;
	while(cin>>t && t)
	{
		cin>>n;
		int ans=0;
		for(int i=0; i<n; i++)
		{
			int a,b;
			cin>>a>>b;
			ans+=b-a;
		}
		if(ans>t)puts("OK");
		else cout<<t-ans<<endl;
	}
	
	return 0;
}

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

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

C++: //============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int t,n,s,f;
	int R;
	while(1){
		R=0;
		cin>>t;
		if(t==0) break;
		cin>>n;
		for(int i=0;i<n;i++){
			cin>>s>>f;
			R+=f-s;

		}
		if(t>R) cout<<t-R<<endl;
		else cout<<"OK"<<endl;
	}







	return 0;
}

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

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

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

int main(){
  while(1){
  int t,n;
  
  cin >> t;
  if(t<=0){
	break;
  }
  cin >> n;

  int s[n],f[n];
  int all=0;

  for(int i=0;i<n;i++){
	cin >> s[i] >> f[i];
	all+=f[i]-s[i];
  }

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

  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main(){

	int t;
	int n;
	while(cin>>t,t!=0){
		cin>>n;
		int s,f;
		int x=0;
		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<iostream>
using namespace std;
int main(){
  int t,n,ans,st,st2;
  while(cin>>t){
    if(t==0) break;
    cin >> n;
    ans = 0;
    for(int i=0;i<n;i++){
      cin >> st >> st2;
      ans += st2 - st;
    }
    if(ans>=t) cout << "OK" << endl;
    else cout << t - ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int main(){
   int t;
   while(scanf("%d",&t) != EOF, t ){
      int n;
      scanf("%d",&n);
      int tot = 0;
      int data[n][2];
      rep(i,n){
         scanf("%d %d",&data[i][0],&data[i][1]);
      }
      rep(i,n){
         tot += data[i][1] - data[i][0];
      }
      if( tot < t){
         printf("%d\n",t-tot);
      }else{
         printf("OK\n");
      }
   }
   return 0;
}

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

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

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