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<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

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

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

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

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

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

  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

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

C++: #include <stdio.h>

int main()
{
	int s,f,t,total;
	int i,j,n;
	
	scanf("%d",&t);
	while(t != 0){
		//初期化
		total = 0;

		scanf("%d",&n);
		for(i = 0; i < n; i++){
			scanf("%d%d",&s,&f);
			total += f-s;
		}

		if(total < t)	printf("%d\n",t-total);
		else			printf("NO\n");

		scanf("%d",&t);
	}

	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int t,n,s,f,i,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=sum+(f-s);
		}
		if(sum>=t){
			printf("OK\n");
		}
		else{
			printf("%d\n",t-sum);
		}
	
	}
	return 0;
}

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

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

C++: #include<iostream>

using namespace std;

int main()
{
	while(true)
	{
		int t = 0, n = 0, s = 0, f = 0, sum = 0;

		cin >> t;

		if(t == 0)
		{
			return false;
		}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,j,k,n,t,sum,a,b;
	
	while(cin>>t&&t) {
		cin>>n;
		sum=0;
		for(i=0;i<n;i++) {
			cin>>a>>b;
			sum+=b-a;
		}
		if(sum>=t) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
	}
}

C++: #include <cstdio>
#include <set>

using namespace std;

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

inline int getInt(){ int s; scanf("%d", &s); return s; }

int main(){
  while(const int t = getInt()){
    const int n = getInt();
    int sum = 0;

    REP(i,n){
      const int s = getInt();
      const int f = getInt();

      sum += f - s;
    }

    if(t <= sum) puts("OK");
    else printf("%d\n", t - sum);
  }

  return 0;
}

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

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


	}
return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int jikan(int s,int f){
	return f-s;
	}
int main(){
	int t,n,s[10],f[10],gokei;
	while(cin>>t){
	if(t==0) break;
	gokei=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i]>>f[i];
		gokei+=jikan(s[i],f[i]);
		}
		if(gokei>=t){
			cout<<"OK"<<endl;
			}
			else cout<<t-gokei<<endl;
			}
	return 0;
}

C++: #include<iostream>
#include<cstdio>

int main(){
	int t, n;
	while(std::cin >> t >> n, !std::cin.eof()){
		int sum = 0;
		while(n--){
			int s, f;
			std::cin >> s >> f;
			sum += f - s;
		}
		if(sum >= t){
			puts("OK");
		}else{
			printf("%d\n", t-sum);
		}
	}
}

C++: #include<iostream>

int main(void){
	using namespace std;

	int time1, time2, moku, kekka, kai;
	kekka = 0;
	while(1){
		cin >> moku;
		if(moku == 0){
			break;
		}
		cin >> kai;
		for(int i = 0;i < kai;i++){
			cin >> time1;
			cin >> time2;
			kekka = kekka + (time2 - time1);
		}
		if(moku <= kekka){
			cout << "OK" <<endl;
		}else{
			cout << moku - kekka << endl;
		}
	}

	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int t,sum,s,e,n;

	while(true){
		scanf("%d",&t);
		if(t == 0)break;

		scanf("%d",&n);

		sum = 0;

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

		if(sum >= t){
			printf("OK\n");
		}else{
			printf("%d\n",t-sum);
		}

	}


    return 0;
}