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

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

using namespace std;

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

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

int main(){
	int t, n, s, f;
	while(scanf("%d%d", &t, &n) == 2){
		for(int i = 0; i < n; ++i){
			scanf("%d%d", &s, &f);
			t -= f - s;
		}
		printf(t > 0 ? "%d\n" : "OK\n", t);
	}
}

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

int main(){
    int t, n;
    while(1){
        cin >> t;
        if(!t) break;
        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;
    }
    
    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);
		}
	}
		return 0;
}

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

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

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