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 <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
using namespace std;
 
const int MAX= 10000100;
 
int main(void){
  int t,n;
  int ans;
  while(cin>>t,t){
    ans = 0;
    cin>>n;
    for(int i = 0 ; i < n ; i ++){
      int s,e;
      cin>>s>>e;
      ans+=e-s;
    }
    //cout<<t<<" "<<ans<<endl;
    if(ans>=t)cout<<"OK"<<endl;
    else cout<<t-ans<<endl;
   }
}

C++: #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int t,i,n,s,f,sum;
	while(1)	{
		scanf("%d",&t);
		if(t==0)	break;
		scanf("%d",&n);
		sum=0;
		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<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <strstream>
#include<vector>
using namespace std;

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

C++: ?°??\???§??????

C++: #include<iostream>

using namespace std;

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

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

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

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

using namespace std;

int main()
{
	int t;
	while(cin >> t && t)
	{
		int n;
		cin >> n;

		int ret = 0;
		rep(i,n)
		{
			int a,b;
			cin >> a >> b;
			ret += b - a;
		}

		if(t - ret <= 0) cout << "OK" << endl;
		else cout << t - ret << endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int a,b,c[100],d[100],i,n;
	scanf("%d",&a);
	scanf("%d",&b);
	while(a!=0){
		for(i=1;i<=b;i++){
			scanf("%d %d",&c[i],&d[100]);
			if(c[i]<d[i]){
				n+=d[i]-c[i];
			}
			else{
				n+=c[i]-d[i];
			}
		}
		if(a<=n){
			printf("OK\n");
		}
		else{
			n=a-n;
			printf("%d\n",n);
		}
	scanf("%d",&a);
	scanf("%d",&b);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

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

int main(void)
{
	int t,n;
	int a,b;
	int sum;

	while(1)
	{
		cin >> t;
		if(t == 0)
			return 0;

		cin >> n;

		sum = 0;
		for(int i=0;i<n;++i)
		{
			cin >> a >> b;
			sum += b - a;
		}
		if(t <= sum)
			cout << "OK" << endl;
		if(t >= sum)
			cout << t - sum << endl;
	}
	return 0;
}

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

int main()
{
  int t, n, a, b, sub;
  
  while(cin >> t, t) {
    cin >> n;
    vector<int> s, f;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      s.push_back(a);
      f.push_back(b);
    }

    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
      sub = f[i] - s[i];
      sum += sub;
    }

    if(sum >= t) {
      cout << "OK" << endl;
    }
    else {
      cout << t-sum << endl;
    }
  }
  
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int a,b,i;
	int aa[i],bb[i];
	int time=0,sa;
	while(1){
		cin >> a;
		if(a==0) break;
		cin >> b;
		for(i=0;i<b;i++){
			cin >> aa[i] >> bb[i];
			sa=bb[i]-aa[i];
			time=time+sa;
		}
		if(time>=a) cout << "OK" << endl;
		if(time<a) cout << a-time << endl;
		time=0;
}
	return 0;
}

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

    

}

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

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

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

using namespace std;

int main(){

	int t,n,s[10],f[10],sum;

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

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>
#include <vector>
using namespace std;

int main()
{
  int t, n, a, b, sub;
  vector<int> s, f;
  
  while(cin >> t, t) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      s.push_back(a);
      f.push_back(b);
    }

    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
      sub = f[i] - s[i];
      sum += sub;
    }

    if(sum >= t) {
      cout << "OK" << endl;
    }
    else {
      cout << t-sum << endl;
    }
  }
  
  return 0;
}

C++: // 2014/09/11 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t;
		cin >> t;

		if(t==0)
			break;

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int t;
  while(cin >> t) {
    if(t == 0) return 0;
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 0, n) {
      int a, b;
      cin >> a >> b;
      ans += b - a;
    }

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

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

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