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 = 0;
  while(cin>>t,t){
    cin>>n;
    for(int i = 0 ; i < n ; i ++){
      int s,e;
      cin>>s>>e;
      ans+=e-s;
    }
    if(ans>t)cout<<"OK"<<endl;
    else cout<<t-ans<<endl;
   }
}

C++: #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int t, n;
        cin >> t >> n;
        if(t == 0)
            return 0;

        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 main(void)
{
  while (true)
  {
    int goal;
    cin >> goal;
    if ( goal == 0 ) break;
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
      int start, finish;
      cin >> start >> finish;
      sum += finish - start;
    }
    if (sum < goal)
    {
      cout << goal - sum << endl;
    }
    else
    {
      cout << "OK" << endl;
    }
  }
  return 0;
}

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;
	}
}

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

int main(void){
	int t,n,m,l;
	while(1){
		int ans=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(int a=0;a<n;a++){
			scanf("%d%d",&m,&l);
			ans+=l-m;
		}
		if(ans>=t)printf("OK\n");
		else printf("%d\n",t-ans);
	}
	return 0;
}

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

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;

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

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

    return 0;
}

C++: // 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" << '\n';
		}
		else{
			cout << t-sum << '\n';
		}
	}

	return 0;
}

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

using namespace std;


int main() {
	int t, n, s, f, sum;

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

	return 0;
}

C++: #include<cstdio>
int t,n,s,f,i,q;
int main()
{
    while(1)
    {
        scanf("%d",&t);
        if(!t){break;}scanf("%d",&n);q=0;
        for(i=0;i<t;i++)
        {
            scanf("%d%d",&s,&f);q+=f-s;
        }
        q<n?printf("%d\n",n-q):printf("OK\n");
    }
}

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 t;

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

        cin >> n;
        while (n--) {
            cin >> s >> f;
            t -= f - s;
        }
        if (t > 0)
            cout << t << endl;
        else
            cout << "OK" << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

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

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

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

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

int main(){
	while(1){
		int t, n, time = 0;

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

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

			time += f-s;
		}

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

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

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

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
  int t,n,k=0,ans=0;
  int s[11],f[11];
  int sa[105];
  t=1;
  cin>>t;
  while(t!=0){
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>s[i]>>f[i];
      if(f[i]<s[i]){
	ans+=(24-s[i]+f[i]);
      }else{
	ans+=(f[i]-s[i]);
      }
    }
    if(ans<t){
      sa[k]=t-ans;
    }else{
      sa[k]=0;
    }
    k++;
    cin>>t;
    ans=0;
  }
  for(int i=0;i<k;i++){
    if(sa[i]==0){
      cout<<"OK"<<"\n";
    }else{
      cout<<sa[i]<<"\n";
    }
  }
  return 0;
}

C++: using System;

class Program
{
    static void Main(string[] args)
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }
}