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>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

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

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

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

int main(){

  int n;

  while(cin >> n, n){
    int m,a,b,time = n;

    cin >> m;

    for(int i=0;i<m;i++){
      cin >> a >> b;

      n -= (b-a);
    }

    if(n <= 0) cout << "OK" << endl;
    else cout << n << 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 x;
	while(1){
		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;
	}

	return 0;
}

C++: #include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


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

C++: #include <iostream>

using namespace std;
 
int main()
{
    int t, n, s, f, total;

    while (cin >> t, t) {
        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<stdio.h>
int main (void)
{
	int t,n,s,f,i,t1,t2,t3;
		scanf("%d",&t);
		scanf("%d",&n);
	while(t!=0){
		for(i=1;i<=n;i++){
				scanf("%d %d",&s,&f);
				t1=f-s;
				t2+=t1;
		}
		scanf("%d",&t);
		scanf("%d",&n);
	}
		if(t2>t){
			printf("OK\n");
		}
		else{
			t3=t-t2;
			printf("%d\n",t3);
		}
	
	return 0;
}

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

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

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

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

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

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS =1e-10;
double EQ(double a,double b){
	return abs(a-b)<EPS;
}

void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

void solve(){
	int n,t,a,b,tt;
    while(cin>>t,t){
	    cin>>n;
tt=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			tt+=b-a;
		}
		if(t<=tt) cout<<"OK"<<endl;
		else cout<<t-tt<<endl;
	}
}

int main(){
solve();
}

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

int main(){
	int t, n;
	while(1){
		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;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
#define print(Target) cout << Target << '\n'
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

signed main()
{
  ios::sync_with_stdio(false);
  int t;

  while (cin >> t, t){
    int n;
    int sum = 0;
    cin >> n;
    REP(i, n){
      int s, f;
      cin >> s >> f;
      sum += f - s;
    }
    sum >= t ? print("OK") : print(t - sum);
  }

  return (0);
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
    int t, n, s, f;
    int total;
    while (cin>>t, t) {
        total = 0;
        cin>>n;
        for (int i = 0; i < n; ++i) {
            cin>>s>>f;
            int tmp = f - s;
            total += tmp;
        }

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

    }
    return 0;
}

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

C++: #include<iostream>

using namespace std;

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