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<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b;
	for (int h = 0; h < 100; h++) {
		int c = 0, sum = 0; int test[123456] = { 0 };
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin  >> a >> b;
			sum += b - a;
		}
		if (sum >= n) {
			cout << "OK" << endl;
		}
		else {
			cout << n - sum << endl;
		}
	}
	cin >> n;
}

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

int main()
{
  int n;

  while (cin >> n && n != 0){
    int a;
    int sum = 0;
    cin >> a;
    while (a--){
      int s, d;
      cin >> s >> d;
      sum += (d - s);
    }
    if (sum > n) cout << "OK" << endl;
    else cout << n - sum << endl;
  }

  return 0;
}

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

int main(){
 int t,i,k,n,s[10],f[10],a=0;
	while(cin>>t){
		if(t==0){
			break;
		}	
	cin>>n;
		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 <iostream>
using namespace std;
int main (){
       int a;
       while(cin>>a){
            if(a==0)break;
            int N;
            cin>>N;
            int ans=0;
            for(int i=0;i<N;i++){
                      int c,d;
                      cin>>c>>d;
                       ans+=d-c;
               }
                       if(ans>a){
                              cout<<"OK"<<endl;
                        }
                        else{   cout<<"NO"<<endl;
                      }   
                }
         return 0;
  }

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

int main(){
    int t;
    while(cin >> t, t){
        int n, sum = 0;
        cin >> n;
        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++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int t;
  while (cin >> t, t) {
    int n;
    cin >> n;
    int c = 0;
    while (n--) {
      int s, f;
      cin >> s >> f;
      c += f - s;
    }
    if (t <= c) {
      cout << "OK" << endl;
      continue;
    }
    cout << t - c << endl;
  }
}

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

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

C++: #include<iostream>

using namespace std;

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

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

using namespace std;

int t,n;
int s,f;

int main()
{
	while(cin>>t)
	{
		if(!t) return 0;

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

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

	}
	return 0;
}

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

C++: #include<iostream>
using namespace std;
int main() {
	int aa;
	while (cin>>aa&&aa){
		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;
		}
	}

	return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    while (1) {
        int t;
        cin >> t;
        if (t == 0)break;
        int n;
        cin >> n;
        FOR(i, 0, n) {
            int s, f;
            cin >> s >> f;
            t -= f - s;
        }
        if (t <= 0)cout << "OK\n";
        else cout << t << "\n";
    }
}