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 time,n;
  while( cin >> time,time ){
    cin >> n;
    int sum = 0;
    for(int i = 0 ; i < n ; i++ ){
      int a,b;
      cin >> a >> b;
      sum+=b-a;
    }
    if(sum < time)cout << time - sum << endl;
    else cout << "OK" << endl;
  }
  return 0;
}

C++: #include <iostream>

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 s, f; cin >> s >> f;
			sum += f - s;
		}

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

C++: #include<iostream>
using namespace std;
int main(){
	int time,abcd,abcd2,hitu;
	while(1){
		int goukei=0;
		cin>>hitu;
		if(hitu==0)break;
		cin>>time;
		for(int abc=0;abc<time;abc++){
			cin>>abcd>>abcd2;
			goukei+=abcd2-abcd;
		}
		if(hitu<=goukei){
			cout<<"OK"<<endl;
		}else{
			cout<<hitu-goukei<<endl;
		}
	}
	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

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

C++: #include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        cout<<i<<": ";
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}

struct Edge{
    int to,cost;
};

bool issorted(vector<int>& v){
    for(int i=1;i<v.size();i++){
        if(v[i-1]>v[i])return false;
    }
    return true;
}

signed main (){
    int n;
    while(cin>>n){
        if(n==0)break;
        int t;cin>>t;
        int ans=0;
        rep(i,0,t){
            int s,e;cin>>s>>e;
            ans+=e-s;
        }
        if(ans>=n)cout<<"OK"<<endl;
        else cout<<n-ans<<endl;
    }
    
}







    


/*
*/

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

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

C++: 
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int t,n,s[10],f[10],i,sa[10]={0},h=0;
    while(cin>>t){
        if(t==0)break;
        cin>>n;
        for(i=0;i<n;i++){
            cin>>s[i]>>f[i];
            sa[i]=f[i]-s[i];
            h+=sa[i];
        }
        if(t<=h)cout<<"OK"<<endl;
        else cout<<t-h<<endl;
        h=0;
    }
          return 0;
}

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

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

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

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

    int n,s[10],e[10];
    cin >> n;

    for(int i = 0;i < n;i++) cin >> s[i] >> e[i];

    int ans = 0;
    for(int i = 0;i < n;i++) ans += (e[i] - s[i]);

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

  }

  return 0;
}