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

Python: # Aizu Problem 0238: Time to Study

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    T = int(input())
    if T == 0:
        break
    n = int(input())
    for _ in range(n):
        start, end = [int(_) for _ in input().split()]
        T -= (end - start)
    print("OK" if T <= 0 else T)

Python: while True:
  t=int(input())
  if t==0:
    break
  n=int(input())
  c=0
  for i in range(n):
    a,b=map(int,input().split())
    c+=(b-a)
  if t<=c:
    print("OK")
  else:
    print(t-c)

Python: #標準入力をし0だった場合はループを抜ける
while True:
    num = int(input())
    if num == 0:break
    else:
        num1 = int(input())
        kei = 0
        
        #勉強時間の合計を計算する
        for _ in range(num1):
            a,b = map(int,input().split())
            kei += b - a
            
        #勉強時間が足りてたら"OK"足りてなかったら足りない時間を出力する
        if num <= kei:print("OK")
        else:print(num - kei)

Python: while 1:
    t = int(input())
    if t == 0:break
    n = int(input())
    s = 0
    for _ in range(n):
        a, b = map(int, input().split())
        s += b - a
    print("OK" if s >= t else t - s)

Python: while 1:
    t=int(input())
    if t==0:break
    n=int(input())
    for i in range(n):
        s,f=map(int,input().split())
        t-=f-s
    if t<1:print("OK")
    else:print(t)

Python: while 1:
    t = int(input())
    if t == 0:
        break
 
    n = int(input())
 
    ans = 0
    for _ in range(n):
        s, f = map(int, input().split())
        ans += f - s
 
    if ans >= t:
        print("OK")
    else:
        print(t - ans)

Python: while True:
  t = int(input())
  if t == 0:
    break
    
  n = int(input())
  
  ans = 0
  for _ in range(n):
    s, f = map(int, input().split())
    ans += f - s
    
  if ans >= t:
    print('OK')
  else:
    print(t - ans)

Python: import sys,os
while 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    sf = [list(map(int, input().split())) for _ in range(n)]
    
    time = 0
    for i in sf:
        start,end = i
        if start > end:
            time += end - (start-24)
        else:
            time += end - start
    if time >= t:
        print("OK")
    else:
        print(t-time)

Python: while 1:
    t = int(input())
    if t == 0:break
    n = int(input())
    x = 0
    for i in range(n):
        x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
    print('OK' if t<=x else (t-x))
while 1:
    t = int(input())
    if t == 0:break
    #n = int(input())
    #x = 0
    #for i in range(n):
    t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
    print('OK' if t<=0 else t)

Python: while True:
  t = int(input())
  if t == 0:
    break
  n = int(input())
  acc = 0
  for _ in range(n):
    s, f = map(int, input().split())
    acc += f - s
  if acc >= t:
    print("OK")
  else:
    print(t - acc)

Python: # -*- coding: utf-8 -*-
"""
Time to Study
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0238

"""
import sys


def solve(t):
    n = int(input())
    for _ in range(n):
        s, f = map(int, input().split())
        t -= (f-s)
    return 'OK' if t <= 0 else t


def main(args):
    while True:
        t = int(input())
        if t == 0:
            break
        ans = solve(t)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while 1:
    t = int(input())
    if t == 0:
        break
    n = int(input())
    T = 0
    for i in range(n):
        s,f = map(int,input().split())
        T += f - s

    if T >= t:
        print("OK")
    else:
        print(t-T)

Python: while 1:
    a=int(input())
    if a == 0: break
    b=int(input())
    d=0
    for _ in range(b):
        c=list(map(int,input().split()))
        d+=c[1]-c[0]
    print(a-d if a>d else 'OK')

Python: t=int(input())
n=int(input())
b=0
for i in range(n):
    s,f=map(int,input().split())
    a=f-s
    b+=a
if t<=b:
    print("OK")
else:
    print(t-b)

Python: while 1:
    t = int(input())
    if t == 0:break
    n = int(input())
    x = 0
    for i in range(n):
        x += (lambda lst:lst[-1] - lst[0])(list(map(int,input().split())))
    print('OK' if t<=x else (t-x))

Python: while 1:
    t = int(input())
    if t == 0:
        break
  
    n = int(input())
  
    ans = 0
    for _ in range(n):
        s, f = map(int, input().split())
        ans += f - s
  
    if ans >= t:
        print("OK")
    else:
        print(t - ans)

Python: while 1:
    t = int(input())
    if t == 0:break
    t -= sum(map(lambda lst:lst[-1] - lst[0],[ list(map(int,input().split())) for i in range(int(input())) ]))
    print('OK' if t<=0 else t)

Python: while 1:
    a=int(input())
    if a == 0: break
    b=int(input())
    for _ in range(b):
        c=list(map(int,input().split()))
        a-=c[1]-c[0]
    print(a if a>0 else 'OK')

Python: while True:
    t= int(input())
    if t== 0: break
    n= int(input())
    c= [list(map(int, input().split())) for _ in range(n)]
    sf= sum(c[i][1]-c[i][0] for i in range(n))
    print("OK" if t<= sf else t-sf)

Python: while True:
    t=int(input())
    n=int(input())
    b=0
    if t == 0:
        break
    for i in range(n):
        s,f=map(int,input().split())
        a=f-s
        b+=a
    if t<=b:
        print("OK")
    else:
        print(t-b)

Python: import sys
f = sys.stdin


while True:
    t = int(f.readline())
    if t == 0:
        break
    n = int(f.readline())
    sf = (map(int, f.readline().split()) for _ in range(n))
    
    rest = t - sum(f - s for s, f in sf)
    print('OK' if rest <= 0 else rest)

Python: while 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    i = 0
    sum = 0
    while i < n:
        s, f = map(int, input().split())
        a = f - s
        sum = sum + a
        i += 1
    if sum < t:
        print(t - sum)
    else:
        print("OK")

Python: # AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u

while 1:
	t = int(input())
	if t == 0: break
	n = int(input())
	sm = 0
	for i in range(n):
		s, f = map(int, input().split())
		sm += f-s
	print("OK" if sm >= t else t - sm)

Python: while True:
    t = int(input())
    if t==0:
        break
    n = int(input())
    hour = 0
    for i in range(n):
        s,f = map(int,input().split())
        hour += (f-s)
        
    if hour >= t:
        print("OK")
    else:
        print(t-hour)

Python: while True:
    a = int(input())
    if a == 0:
        break
    b = int(input())
    for i in range(b):
        c,d = map(int,input().split())
        a -= d-c
    if a <= 0:
        print("OK")
    else:
        print(a)

Python: # AOJ 0238 Time to Study
# Python3 2018.6.25 bal4u
 
while 1:
    t = int(input())
    if t == 0: break
    n = int(input())
    sm = 0
    for i in range(n):
        s, f = map(int, input().split())
        sm += f-s
    print("OK" if sm >= t else t - sm)

Python: while True:
    try:
        t=int(input())
        n=int(input())
        M=0
        for i in range(n):
            s,f=map(int,input().split())
            A=f-s
            M=M+A
        if t>M:
            print(t-M)
        else:
            print("OK")
    except:
        break

Python: while True:
  t=int(input())
  if t == 0: break
  n = int(input())
  for i in range(n):
    s,f=map(int,input().split())
    t-=f-s
  if t<1:
    print("OK")
  else:
    print(t)