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 <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,n,s,f;
  while(cin >> t && t){
    cin >> n;
    rep(i,n){
      cin >> s >> f;
      t -= f-s;
    }
    if(t <= 0)cout <<"OK"<<endl;
    else cout << t << 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;
		else cout<<m-sum<<endl;
	}
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0238

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

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

using namespace std;

int main(){
	int a,b[11],c[11],e,sum;
	
	cin >> e;
	

	
	while(1){
	
		if(e==0) break;
		
		cin >> a;
		
		sum=0;
		
		for(int i=0;i<a;i++) cin >>b[i] >>c[i];
		
		for(int i=0;i<a;i++){
			if(b[i]-c[i]<0){
				sum+=(-1*(b[i]-c[i]));
			}else sum+=b[i]-c[i];
		}
		
		if(e<=sum){
			printf("OK\n");
		}else printf("%d\n",e-sum);
		
		cin >> e;
		
		
	}
	return 0;
}

C++: // 2014/05/23 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" << endl;
		}
		else{
			cout << t-sum << endl;
		}
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

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

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

int main(){


  int sum;

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

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long int lli;
int int_compare(const void* a, const void* b) { return *(int*)a - *(int*)b; }
int lli_compare(const void* a, const void* b) { return *(lli*)a - *(lli*)b; }
//qsort(dat,NUM,sizeof(int),int_compare);
int main(void)
{
	int n, t;
	static int a[100000], b[100000];
	int cnt, flg;

	do {
		scanf("%d", &t);
		if (t == 0)break;
		scanf("%d", &n);
		flg = cnt = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &a[i], &b[i]);
			cnt += b[i] - a[i];
		}
		if (cnt<t) {
			printf("%d\n", t-cnt);
		}
		else {
			printf("OK\n");
		}
	} while (t != 0);
	
	return 0;
}

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

int main(){
	int goal;
	while(cin >> goal, goal){
		int n;
		cin >> n;
		for(int i=0; i < n; i++){
			int start, end;
			cin >> start >> end;
			goal -= (end - start);
		}
		if(goal <= 0) cout << "OK" << endl;
		else cout << goal << endl;
	}
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    while(cin>>t&&t){
        int n;
        cin>>n;
        int sum=0;
        for(int i=0,s,f;i<n;i++){
            cin>>s>>f;
            sum+=f-s;
        }
        if(sum>=t)cout<<"OK"<<endl;
        else cout<<t-sum<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

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

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

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

  return 0;
}