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<bits/stdc++.h>
using namespace std;

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

  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int m;
    int sum=0;
    cin>>m;
    rep(i,m){
      int a,b;
      cin>>a>>b;
      sum+=b-a;
    }
    if(sum>=n)cout<<"OK"<<endl;
    else cout<<n-sum<<endl;
  }

}

C++: // #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN(){T d;cin>>d;return d;}
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b){ return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b){ return a / gcd(a, b) * b; }

// ------------------- include, typedef, define END. -------------------

int main(){
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;
	
	//??????????????????????????????.
	int t;
	while(cin>>t, t){
		int nowTime = 0;
		int n=0;
		cin >> n;
		FOR(i,0,n){
			int s=0,f=0;
			cin >> s >> f;
			nowTime += f-s;
		}
		if(t <= nowTime)
			cout << "OK" << endl;
		else
			cout << (t - nowTime) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){

	int t,sum,s,f,n;

	while(true){
		cin >> t;
		if(t == 0)break;

		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<stdio.h>
int main(void)
{
	int n,t,i,k,h,x,w;
	w=0;
	while(1){
	scanf("%d",&n);
	if(n==0) break;
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d %d",&k,&h);
		w+=h-k;
//		printf("%d\n",w);
		}
	if(n<w){
		printf("OK\n");
		}
	else{
		x=n-w;
		printf("%d\n",x);
		}
	}
		return 0;
}

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

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;
}
			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;

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

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

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

C++: #include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int t, n;
	while( scanf( "%d", &t ), t )
	{
		scanf( "%d", &n );

		rep( i, n )
		{
			int s, f;
			scanf( "%d%d", &s, &f );
			t -= f-s;
		}

		if( t > 0 )
			printf( "%d\n", t );
		else
			puts("OK");
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int t, n;
	int s, f;
	while (1) {
		cin >> t;
		if (t == 0)break;
		cin >> n;
		int 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 <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){

    return 0;
}
*/

//y11-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    while(true){

    int t,n;
    cin >> t;
    if(t == 0) return 0;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n; i++){
        int s,f;
        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;

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

int main()
{
	solve();
	return(0);
}