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>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
while (true) {
  std::cin >> x;
  if(x==0)break;
std::cin >> y;
rep(i,y){
  std::cin >> z>>w;
  n+=w-z;
}
if(n>=x)std::cout << "OK" << '\n';
else std::cout << x-n << '\n';
n=0;
}
}

C++: #include<iostream>

int main(void){
	using namespace std;

	int time1, time2, moku, kekka, kai;
	while(1){
		kekka = 0;
		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<iostream>
using namespace std;
int main(){
  while(true){
    int t;cin>>t;
    if(t == 0)return 0;

    int n; cin >> n;
    int result= 0;
    for(int i = 0; i < n; i++){
      int time[2] = {};
      cin >>time[0] >> time[1];
      result += time[1]-time[0];
    }
    (result > t)?(cout << "OK"<<endl):(cout<<t-result<<endl);
}
  return 0;
}

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

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

C++: #include<iostream>

using namespace std;

int main(){
  int t,n;

  while(cin>>t,t){
    int total=0;
    cin>>n;

    for(int i=0;i<n;++i){
      int a,b;
      cin>>a>>b;
      total+=b-a;
    }

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

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

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

using namespace std;

int main()
{
	int n, t;
	int st, fi;

	while (scanf("%d", &t), t != 0){
		int t_cnt = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; i++){
			scanf("%d%d", &st, &fi);
			t_cnt += fi - st;
		}
		if (t <= t_cnt){
			cout << "OK" << endl;
		}
		else {
			cout << t - t_cnt << endl;
		}
	}

	return (0);
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

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

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	for(;;){
        int t,n;
        cin>>t;
        if(t==0)break;
        cin>>n;
        int a,b;
        int w=0;
        for(int i=0;i<n;i++){
            cin>>a>>b;
            w+=b-a;
        }
        if(w>=t)cout<<"OK"<<endl;
        else cout<<t-w<<endl;
	}
	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<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
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");
	}
	return 0;
}

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

using namespace std;

int main() {
	int t;

	while (cin >> t, t) {
		int n;
		cin >> n;

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

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

C++: #include<stdio.h>
int main(void) 
{
	int t, n, s, f,a,b,c=0,d;
	scanf("%d", &t);
	scanf("%d", &n);
	for (a = 1;a <= n;a++)
	{
		scanf("%d %d", &s, &f);
		b = f - s;
		c = c + b;
	}
	d = t - c;
	if (d > 0)
	{
		printf("%d\n",d);
	}
	else
	{
		printf("ok\n");
	}
	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>=10){
				printf("OK\n");
			}
			else{
				printf("2\n");
			}
		scanf("%d",&t);
	}
	return 0;
}

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

C++: #include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int t;
    while (t = in()){
        int n = in();
        int total_time = 0;
        rep(i, n) total_time += abs(in() - in());
        if (total_time < t) printf("%d\n", t - total_time);
        else puts("OK");
    }

    return (0);
}