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<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+=f-s;
		}
		if(sum>=t){
			printf("OK\n");
		}
		else{
			printf("%d\n",f-sum);
		}
	
	}
	return 0;
}

C++: // 2015/03/09 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 <iostream>
#include <vector>

using namespace std;

int n, t;

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

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

int main(void){
  int t,n,s,f,total;

  for(;;){
    total = 0;

    cin >> t;
    if( t == 0 ) break;

    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<iostream>
using namespace std;

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

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

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

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

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

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

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

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int T;
    while(cin >> T&&T){
		int N;
		cin >> N;
		int sum=0;
		REP(i,0,N){
			int S,F;
			cin >> S >> F;
			sum+=F-S;
		}
		if(sum>=T) cout << "OK";
		else cout << T-sum;
		cout << endl;
	}
	return 0;
}

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

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

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int t,n,a,b,sum=0;
	cin>>t>>n;
	while(n!=0){
		for (int A=0;A<n;A++){
			cin>>a>>b;
			sum+=b-a;
		}
		if (sum>=t) cout<<"OK"<<endl;
		else cout<<t-sum<<endl;
		sum=0;
		cin>>t>>n;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int time, n, start, finish;
  while (cin >> time, time) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> start >> finish;
      time -= finish - start;
    }
    if (time > 0)
      cout << time << endl;
    else
      cout << "OK" << endl;
  }
  return 0;
}

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

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

int main() {
    for(int T; cin >> T, T; ) {
        int N; cin >> N;
        while(N--) {
            int a, b; cin >> a >> b;
            T -= b - a;
        }
        if(T <= 0) cout << "OK" << endl;
        else cout << T << endl;
    }
}

C++: #include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

int t,n,s,f,sum;

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(void){
	int t,n;
	int i;
	int x,y;
	int sum;
	while(1){
		cin>>t;
		if(t==0)	break;
		cin>>n;
		sum=0;
		for(i=0;i<n;i++){
			cin>>x>>y;
			sum+=y-x;
		}
		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<stdio.h>
int main(void)
{
	int t,n,datas[100],dataf[100],i,j,m,s;
	scanf("%d",&t);
	while(t !=0){
		j=0;
		scanf("%d",&n);
			for(i=0;i<n;i++){
				scanf("%d %d",&datas[i],&dataf[i]);
				j+=dataf[i]-datas[i];
			}
			m=t-j;		
				if(m<0){
					printf("OK\n");
				}
				else if(m>0){
					printf("%d\n",m);
				}
				else{
					printf("OK\n");
				}
			
		scanf("%d",&t);
	}
		return 0;
}

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

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

using namespace std;

int n, t;

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