Help me in solving MAX_DIFF problem wrong value for input t=1,n=5,s=6

My issue

the code i have written is showing correct results in other compilers but in codechef it is giving me negative values

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
    Scanner read=new Scanner(System.in);
    int t=read.nextInt();
    while(t>0)
    {
        int n = read.nextInt();
        int s = read.nextInt();
        if(n==s)
        {
            System.out.println(n);
        }
        else if(s==1)
        {
            System.out.println(s);    
        }
        else
        {
            System.out.println(n-(s-n));
             
        }
        t--;
    }
	}
}

Learning course: Level up from 1* to 2*
Problem Link: The Two Dishes Practice Problem in Level up from 1* to 2* - CodeChef

@mayank_bhatt
for
1
10 6
your code will print 14 which is wrong
the answer would be 6.