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

int main()
{
	int t, n, m;

	cin >> t;
	
	while (t > 0) {
		cin >> n;
		m = 0;

		for (int i = 0; i < n; i++) {
			int s, f;
			cin >> s >> f;

			m += f - s;
		}

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

		cin >> t;
	}

	return 0;
}

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

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

int main() {
  int t;
  while (1) {
    cin >> t;
    if (t == 0) break;

    int n;
    cin >> n;
    int s, f, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s >> f;
      sum += f - s;
    }

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

  return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int t,n,s,f,sum;
	
	while(1){
		sum = 0;
		cin >> t;
		if(t == 0) break;
		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;
	}
	return 0;
}

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

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

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

C++: #include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t, tt, n;
    while(true) {
        cin >> t;
        if(t == 0) break;

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

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

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

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

C++: #include <iostream>
using namespace std;
int main()
{
  for(;;){
    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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	while(1){
	    int t,n,time = 0;
	    cin >> t;
	    if(t == 0) break;
	    cin >> n;

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

	return 0;
}

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

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

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

int main() {

  int n;
  
  while(1) {
    int sum = 0;
    cin >> n;
    if(n == 0) break;

    int t;
    cin >>t;
    
    for(int i=0;i<t;i++) {
    int s,f;
    cin >> s >>f;

    sum += f-s;

    }

    if(sum < n) cout << n-sum << endl;
    else cout <<"OK"<<endl;

  }

  return 0;

}

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

int main(){

	int t, n, s,f,i,cou;
	
	
	while(1){


		cou = 0;

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

		for(i = 0;i < n;i ++){

			cin >> s >> f;			
			cou += f - s;
		}

		cou = t - cou;


		if(cou <= 0) cout<< "OK" << endl;
		else if(cou > 0)cout << cou << endl;
		

		
	
	}

	


}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int target,n;
	while(cin>>target,target){
		cin>>n;
		int begin,end,sum=0;
		for(int i=0;i<n;i++){
			cin>>begin>>end;
			sum+=(end-begin);
		}
		if(sum>=target)cout<<"OK"<<endl;
		else cout<<target-sum<<endl;
	}
}

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

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

C++: #include <bits/stdc++.h>
 
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
 
using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};
 
const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

        REP(i, n)
        {
            int s, f;
            cin >> s >> f;

            sum += f - s;
        }

        cout << (t <= sum ? "OK" : to_string(t - sum)) << endl;
    }
    return 0;
}

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

C++: #include <iostream>

using namespace std;

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