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 <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


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

    }
    return 0;
}

C++: f

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int t, n, s, f;

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

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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int t, n;
int s[30], f[30];
void solve() {
    int sum = 0;
    rep(i, n) sum += f[i] - s[i];
    if (sum >= t) {
        cout << "OK" << endl;
    } else {
        cout << t - sum << endl;
    }
}
int main() {
    while (cin >> t) {
        if(t == 0) break;
        cin >> n;
        rep(i, n) cin >> s[i] >> f[i];
        solve();
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){
	
	int t;
	int n;
	int s,f;
	int i;
	int a=0,b;
	
	while(1){
		a=0;
		scanf("%d",&t);
		if(t==0) break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			a=a+(f-s);
		}
			if(t<=a){
				printf("OK\n");
			}else{
				b=t-a;
				printf("%d\n",b);
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int t, n;

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

C++: #include <iostream>

using namespace std;

int main(){
  while(1){
    int t, n, s, f, ans = 0;
    cin >> t;
    if(t == 0)break;
    cin >> n;

    for(int i = 1;i <= n; i++){
      cin >> s >> f;
      ans += f - s;
    }
    if(t <= ans) cout << "OK" << endl;
    else cout << t - ans << endl;
  }

  return 0;
}

C++: #include <cstdio>

int main(){
	int t;
	for(;;){
		scanf("%d",&t);
		if(t==0) break;
		int n;
		scanf("%d",&n);
		int sum=0,s,f;
		for(int 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);
	}
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(void){
    while(1){
        ll t=0,n;cin>>t;
        if(t==0)break;
        cin>>n;
        ll time=0;
        rep(i,0,n){
          ll s,f;
            cin>>s>>f;
            time+=f-s;
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
    
}

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

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

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

C++: #include <cstdio>
int main(){
    while(1){
        int start,end,target,n;
        scanf("%d",&target);
        if(!target) break;
        scanf("%d",&n);
        while(n--){
            scanf("%d %d",&start,&end);
            target -= end-start;
        }
        if(target>0) printf("%d\n",target);
        else printf("OK\n");
    }
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		int t = 0,n = 0;

		cin >> t;
		if (t == 0)
		{
			break;
		}
		cin >> n;

		int a[11],b[11];

		for (int i = 0; i < n; i++)
		{
			a[i] = 0;
			b[i] = 0;
			cin >> a[i] >> b[i];
		}

		int p = 0;

		for (int i = 0; i < n; i++)
		{
			p += b[i] - a[i];
		}

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

C++: #include<cstdio>

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

using namespace std;

int main(){
	for(int t;scanf("%d",&t),t;){
		int n; scanf("%d",&n);
		rep(_,n){
			int s,g; scanf("%d%d",&s,&g);
			t-=g-s;
		}
		if(t<=0) puts("OK"); else printf("%d\n",t);
	}

	return 0;
}

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

int main(){
 int t,i,k,n,s[10],f[10],a;
	while(cin>>t){
		if(t==0){
			break;
		}	
	cin>>n;
		for(i=0;i<n;i++){
			a=0;			
		cin>>s[i]>>f[i];
		a=a+f[i]-s[i];	
			cout<<a<<endl;			
			}
			if(a>=t){
			cout<<"OK"<<endl;				
				}
			else{
			cout<<t-a<<endl;
				}
	}
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;
}