#include <stdio.h>
#include <string.h>

int subCount(char str[], char sub[]);

int main()
{
	char str[101];
	int nameCount=0;

	scanf(" %s", str);

	nameCount+=subCount(str, "Danil");
	nameCount+=subCount(str, "Olya");
	nameCount+=subCount(str, "Slava");
	nameCount+=subCount(str, "Ann");
	nameCount+=subCount(str, "Nikita");

	if(nameCount==1) printf("YES");
	else printf("NO");

	return 0;
}

int subCount(char str[], char sub[])
{
	int i, j, flag, count=0;

	for(i=0; str[i]!='\0'; i++)
	{
		flag=1;
		for(j=0; sub[j]!='\0'; j++)
		{
			if(str[j+i]!=sub[j])
				flag=0;
		}
		if(flag) count++;
	}
	return count;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{

char string[101];
scanf("%s",string);
int count =0;
for(int i =0 ;i<101;i++){
    if(string[i]!='\0'){
        if(string[i]=='A'&&string[i+1]=='n'&&string[i+2]=='n'){
            count++;
        }
        if(string[i]=='S'&&string[i+1]=='l'&&string[i+2]=='a'&&string[i+3]=='v'&&string[i+4]=='a'){
            count++;

        }
        if(string[i]=='N'&&string[i+1]=='i'&&string[i+2]=='k'&&string[i+3]=='i'&&string[i+4]=='t'&&string[i+5]=='a'){
            count++;
        }
        if(string[i]=='O'&&string[i+1]=='l'&&string[i+2]=='y'&&string[i+3]=='a'){
            count++;
        }
        if(string[i]=='D'&&string[i+1]=='a'&&string[i+2]=='n'&&string[i+3]=='i'&&string[i+4]=='l'){
            count++;

        }
    }
}

if(count==1){
    printf("YES");
}else{
printf("NO");
}
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
	char s[5][7];
	strncpy(s[0], "Danil", sizeof(s[0]));
	strncpy(s[1], "Olya", sizeof(s[1]));
	strncpy(s[2], "Slava", sizeof(s[2]));
	strncpy(s[3], "Ann", sizeof(s[3]));
	strncpy(s[4], "Nikita", sizeof(s[4]));
	char ques[101];
	scanf("%s" ,ques);
	int i,j,k,M,N=strlen(ques),count=0;
	for(i=0;i<5;i++)
	{
		M=strlen(s[i]);
		for(j=0;j<N-M+1;j++)
		{
			k=j;
			while(k<j+M)
			{
				if(s[i][k-j]==ques[k])
				{
					k++;
					continue;
				}
				else
					break;
			}
			if(k==j+M)
				count++;
		}
	}
	if(count==1)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
 int i,j,k,l1,l2,c=0;
 scanf("%s",&s);
l1=strlen(s);
 for(i=0;i<5;i++)
   {
   	l2=strlen(name[i]);
   	for(j=0;j<l1-l2+1;j++)
   	{
   		int f=1;
   		for(k=0;k<l2;k++) if(s[j+k] != name[i][k]) f=0;

   		if(f) c++;
	   }
   }

if(c==1) printf("YES");
else printf("NO");

}

#include <stdio.h>
#include <string.h>

int main()
{
    char name[][7] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
    char str[101];
    int cnt = 0;
    scanf("%s", str);
    int len = strlen(str);
    for(int i = 0; i < 5; ++i) {
        char *p = str;
        while(1) {
            char *q = strstr(p, name[i]);
            if(q != NULL) {
                p = q + 1;
                ++cnt;
            } else {
                break;
            }
            if(p - str >= len) {
                break;
            }
        }
    }
    puts(cnt == 1 ? "YES" : "NO");
    return 0;
}

#include "stdio.h"
#include "string.h"

int StringFind(const char *pSrc, const char *pDst)
{
    int i, j;
    int num = 0;
    for (i=0; pSrc[i]!='\0'; i++)
    {
        if(pSrc[i]!=pDst[0])
            continue;
        j = 0;
        while((pDst[j]==pSrc[i+j])&&(pDst[j]!='\0')&&(pSrc[i+j]!='\0'))
        {
            j++;
        }
        if(j==strlen(pDst))
        {
            num++;
            i += j-1;
        }
    }
    if(num>0)
        return num;
    else
        return 0;
}

int main()
{
    char s[100];
    while(scanf("%s",&s)!=EOF)
    {
        int result = 0;
        result += StringFind(s,"Danil");
        result += StringFind(s,"Olya");
        result += StringFind(s,"Slava");
        result += StringFind(s,"Nikita");
        result += StringFind(s,"Ann");
        if(result==1)
            printf("YES\n");
        else
            printf("NO\n");
    }
}

#include <stdio.h>
#include<string.h>

int main(void)
{
    int i,j,k,n,c=0;
    char str[101],s1[]= "Danil",s2[]="Olya",s3[]="Slava",s4[]="Ann",s5[]="Nikita";
    scanf("%s",str);
    for(i=0;i<strlen(str);i++)
    {
        if(c>=2) {
            printf("NO\n");
            return 0;
        }
        for(k=0,j=i;s1[k]!=0;j++,k++)
            if(str[j]!=s1[k]) break;
        if(k==strlen(s1)) c++;

        for(k=0,j=i;s2[k]!=0;j++,k++)
            if(str[j]!=s2[k]) break;
        if(k==strlen(s2)) c++;

        for(k=0,j=i;s3[k]!=0;j++,k++)
            if(str[j]!=s3[k]) break;
        if(k==strlen(s3)) c++;

        for(k=0,j=i;s4[k]!=0;j++,k++)
            if(str[j]!=s4[k]) break;
        if(k==strlen(s4)) c++;

        for(k=0,j=i;s5[k]!=0;j++,k++)
            if(str[j]!=s5[k]) break;
        if(k==strlen(s5)) c++;
    }
    if(c==1) printf("YES");
    else printf("NO");
    return 0;
}

#include <stdio.h>
#include <string.h>

int substring(char a[], char sub[]) {
	int l1 = strlen(a);
	int l2 = strlen(sub);
	int ans = 0;
	for (int i=0;i<=l1-l2;++i) {
		int k = 0;
		for (int j=0;j<l2;++j) {
			if (a[k+i] == sub[j]) {
				++k;
			} else {
				break;
			}
		}
		if (k==l2) {
			++ans;
		}
	}
	return ans;
}

int main(void) {
	char a[102];
	char *f[] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
	memset(a, '\0', 102*sizeof(char));
	scanf("%s",a);
	int ct = 0;
	for (int i=0;i<5;++i) {
		ct += substring(a, f[i]);
	}
	if (ct == 1)
		printf("YES");
	else
		printf("NO");
	return 0;
}

#include <stdio.h>
int wfind(char c[], int i, char d[])
{
    int f, j;
    for(j=0; ; j++)
    {
        if(d[j]=='\0')
        {
            f=1;
            break;
        }
        if(c[i+j]!=d[j])
        {
            f=0;
            break;
        }
    }
    return f;
}
int main()
{
    int i, a=0 ,b=0,c=0,d=0,e=0,f ,x;
    char w[101];
    fgets(w, 101, stdin);
    for(i=0; w[i]!='\0' ; i++)
    {
        f=wfind(w, i, "Danil");
        a+=f;
        f=wfind(w, i, "Olya");
        b+=f;
        f=wfind(w, i, "Slava");
        c+=f;
        f=wfind(w, i, "Ann");
        d+=f;
        f=wfind(w, i, "Nikita");
        e+=f;
    }
    x=a+b+c+d+e;
    if(x==1)
        puts("Yes");
    else
        puts("NO");
}

#include<stdio.h>
int main()
{
    char string[110];
    while(scanf("%s",string)==1)
    {
        char Danil[]="Danil",Olya[]="Olya", Slava[]="Slava", Ann[]="Ann" , Nikita[]="Nikita";
        int i,j,count=0,index=0,result=0;
        for(i=0;string[i]!='\0';i++)
        {
            j=i;
            index=0;
            char test[10]={0};
            for(;j<i+3;j++)test[index++]=string[j];
            if(strcmp(test,Ann)==0)
            {
                result++;
                continue;
            }
            test[index++]=string[j++];
            if(strcmp(test,Olya)==0)
            {
                result++;
                 continue;
            }
            test[index++]=string[j++];
            if(strcmp(Danil,test)==0 || strcmp(Slava,test)==0)
            {
                result++;
                continue;
            }
            test[index++]=string[j++];
            if(strcmp(test,Nikita)==0)
            {
                result++;
                continue;
            }
        }
        if(result==1)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

#include <stdio.h>

int checkD(char *n, int l, int i)
{
	if(n[i+1]=='a' && n[i+2]=='n' && n[i+3]=='i' && n[i+4]=='l')
		return 1;
	else
		return 0;
}

int checkO(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='y' && n[i+3]=='a')
		return 1;
	else
		return 0;
}

int checkS(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='a' && n[i+3]=='v' && n[i+4]=='a')
		return 1;
	else
		return 0;
}

int checkA(char *n, int l, int i)
{
	if(n[i+1]=='n' && n[i+2]=='n')
		return 1;
	else
		return 0;
}

int checkN(char *n, int l, int i)
{
	if(n[i+1]=='i' && n[i+2]=='k' && n[i+3]=='i' && n[i+4]=='t'&& n[i+5]=='a')
		return 1;
	else
		return 0;
}

int main()
{
	char n[99999];

	int l=0,i,x=0,count=0;

	gets(n);

	while(n[l]) l++;

	for(i=0;i<l;i++)
	{
		if(n[i]=='D')
		{
			x=checkD(n,l,i);
			if(x==1) count++;
		}
		else if(n[i]=='O')
		{
			x=checkO(n,l,i);
			if(x==1) count++;
		}
		else if(n[i]=='S')
		{
			x=checkS(n,l,i);
			if(x==1) count++;
		}
		else if(n[i]=='A')
		{
			x=checkA(n,l,i);
			if(x==1) count++;
		}
		else if(n[i]=='N')
		{
			x=checkN(n,l,i);
			if(x==1) count++;
		}
		/*if(x==1)
		{
			count++;
		}
		else
		{
			continue;
		}*/
	}
	if(count==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
#include <string.h>

int find_word(char s[],char name[]){
	int slen,nlen,i,j,count=0;
	slen=strlen(s);
	nlen=strlen(name);
	for(i=0;i<slen;i++)
	{
			for(j=0;j<nlen;j++)
			{
				if(s[i+j]!=name[j])
				{
					break;
				}
			}
			if(j==nlen)
			count++;
	}
	return count;
}

int main(void) {
	char s[1000];
	int count=0;
	scanf("%s",s);
	count+=find_word(s,"Danil");
	count+=find_word(s,"Olya");
	count+=find_word(s,"Slava");
	count+=find_word(s,"Ann");
	count+=find_word(s,"Nikita");
	if(count==1)printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define MaxNum 106
#define Num 6

int main()
{
    char Name[MaxNum];
    int i,CNikita=0,CAnn=0,CSlava=0,COlya=0,CDanil=0,Sum;
    for(i=0;i<MaxNum;i++){
        Name[i]=0;
    }
    gets(Name);
    for(i=0;i<MaxNum;i++){
        if(Name[i]==0){
            break;
        }
        if(Name[i]=='A' && Name[i+1]=='n' && Name[i+2]=='n'){
            CAnn++;
        }
        if(Name[i]=='S' && Name[i+1]=='l' && Name[i+2]=='a'&& Name[i+3]=='v' && Name[i+4]=='a'){
            CSlava++;
        }
        if(Name[i]=='O' && Name[i+1]=='l' && Name[i+2]=='y' && Name[i+3]=='a'){
            COlya++;
        }
        if(Name[i]=='D' && Name[i+1]=='a' && Name[i+2]=='n'&& Name[i+3]=='i' && Name[i+4]=='l'){
            CDanil++;
        }
        if(Name[i]=='N' && Name[i+1]=='i' && Name[i+2]=='k'&& Name[i+3]=='i' && Name[i+4]=='t' && Name[i+5]=='a'){
            CNikita++;
        }

    }
    Sum=CNikita+CAnn+COlya+CDanil+CSlava;
    if(Sum==1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    //printf("Nikita=%d Ann=%d Slava=%d Olya=%d Danil=%d \n",CNikita,CAnn,CSlava,COlya,CDanil);
    return 0;
}

#include<stdio.h>
#include<string.h>
void arr(char pat[],int m,int *lps)
{
int len=0;
lps[0]=0;
int i=1;
while(i<m){
if(pat[i]==pat[len]){
len++;lps[i]=len;
i++;}
else {
if(len!=0){
len=lps[len-1];}
else {
lps[i]=0;
i++;}}}}
int sea(char pat[],char txt[])
{
int m=strlen(pat);
int n=strlen(txt);
int lps[m];
int count=0;
arr(pat,m,lps);
int i=0,j=0;
while(i<n){
if(pat[j]==txt[i]){
j++;i++;
}
if(j==m){
count++;
j=lps[j-1];}
else if(i<n&&pat[j]!=txt[i]){
if(j!=0)
j=lps[j-1];
else
i=i+1;
}}
return count;}
int main(){
int l1,l2,l3,l4,l5;
char txt[1000];
char pat1[10]="Danil",pat2[10]="Olya",pat3[10]="Slava",pat4[]="Ann",pat5[]="Nikita";
scanf("%s",txt);
l1=sea(pat1,txt);
l2=sea(pat2,txt);
l3=sea(pat3,txt);
l4=sea(pat4,txt);
l5=sea(pat5,txt);
if((l1+l2+l3+l4+l5)==1){
printf("YES\n");}
else printf("NO\n");
return 0;
}

#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[101];
    int count=0;
    gets(str);
    if (strstr(str,"Nikita")) ++count;
    if (strstr(str,"Danil")) ++count;
    if (strstr(str,"Olya")) ++count;
    if (strstr(str,"Slava")) ++count;
    if (strstr(str,"Ann")) ++count;
    if ((strstr(str,"Nikita") && (strstr(strstr(str,"Nikita")+1,"Nikita"))) ||
       ((strstr(str,"Danil")) && (strstr(strstr(str,"Danil")+1,"Danil"))) ||
        ((strstr(str,"Olya")) && (strstr(strstr(str,"Olya")+1,"Olya"))) ||
        ((strstr(str,"Ann")) && (strstr(strstr(str,"Ann")+1,"Ann"))) ||
        ((strstr(str,"Slava")) && (strstr(strstr(str,"Slava")+1,"Slava")))){
        printf("NO");
        return 0;
    }
    if (count==1) printf("YES");
    else printf("NO");
    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int name=0,i;
    char problem_name[100];
    scanf("%s",problem_name);
    for(i=0;i<strlen(problem_name);i++)
    {
       if(problem_name[i]=='D' && i+4<strlen(problem_name))
       {
           if(problem_name[i+1]=='a' && problem_name[i+2]=='n' && problem_name[i+3]=='i' && problem_name[i+4]=='l' )
            {name++;
            i+=4;}
       }
       if(problem_name[i]=='O' && i+3<strlen(problem_name))
       {
           if(problem_name[i+1]=='l' && problem_name[i+2]=='y' && problem_name[i+3]=='a')
            {name++;
            i+=3;}
       }
       if(problem_name[i]=='S' && i+4<strlen(problem_name))
       {
           if(problem_name[i+1]=='l' && problem_name[i+2]=='a' && problem_name[i+3]=='v' && problem_name[i+4]=='a' )
            {name++;
            i+=4;}
       }
       if(problem_name[i]=='A' && i+2<strlen(problem_name))
       {
           if(problem_name[i+1]=='n' && problem_name[i+2]=='n')
            {name++;
            i+=2;}
       }
       if(problem_name[i]=='N' && i+5<strlen(problem_name))
       {
           if(problem_name[i+1]=='i' && problem_name[i+2]=='k' && problem_name[i+3]=='i' && problem_name[i+4]=='t' && problem_name[i+5]=='a' )
            {name++;
            i+=5;}
       }
    }
    if(name==1)
        printf("YES\n");
    else printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void prefix_table(char pattern[],int prefix[], int n)
{
	prefix[0] = 0;
	int len = 0;
	int i = 1;
	while (i < n)
	{
		if (pattern[len] == pattern[i])
		{
			len++;
			prefix[i] = len;
			i++;
		}
		else
		{
			if (len > 0)
			{
				len = prefix[len - 1];
			}
			else
			{
				prefix[i] = 0;
				i++;
			}
		}
	}
}

void move_prefix_table(int prefix[], int n)
{
	for (int i = n - 1; i > 0; i--)
	{
		prefix[i] = prefix[i - 1];
	}
	prefix[0] = -1;
}

int kmp_search(char text[], char pattern[])
{
	int n = strlen(pattern);
	int m = strlen(text);
	int prefix[15];
	prefix_table(pattern, prefix, n);
	move_prefix_table(prefix, n);

	int count = 0;
	int i = 0;
	int j = 0;
	while (i < m)
	{
		if (j == n - 1 && pattern[j] == text[i])
		{
			j = prefix[j];
			count++;
		}
		if (text[i] == pattern[j])
		{
			i++;
			j++;
		}
		else
		{
			j = prefix[j];
			if (j == -1)
			{
				i++;
				j++;
			}
		}
	}
	return count;
}

int main()
{
	int sum = 0;
	char text[105];

	gets(text);

	char pattern1[] = "Danil";
	char pattern2[] = "Olya";
	char pattern3[] = "Slava";
	char pattern4[] = "Ann";
	char pattern5[] = "Nikita";

	sum += kmp_search(text, pattern1);
	sum += kmp_search(text, pattern2);
	sum += kmp_search(text, pattern3);
	sum += kmp_search(text, pattern4);
	sum += kmp_search(text, pattern5);

	if (sum == 1)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}

	return 0;
}

#include <stdio.h>
#include <string.h>
char *f[5]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
int freq(char* str)
{
    int i, c=0;
    for(i=0;i<5;i++)
    {
        char *x=str;
        while(x=strstr(x, f[i]))
        {
            c++;
            x+=strlen(f[i]);
        }
    }
    return c;
}
int main()
{
    char str[100];
    scanf("%s", str);
    if(freq(str)==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

// http://codeforces.com/contest/877/problem/A

#include <stdio.h>
#include <string.h>

typedef enum {
	False,
	True
} bool_t;

typedef struct{
	char * name;
	int name_len;
} friend_t;

int StrCompare(char * str_a, char * str_b, int len_a, int len_b);
bool_t ContainsStr(char * string, char * sub_str, int str_len, int sub_len);
int CountStr(char * string, char * sub_str, int str_len, int sub_len);

#define DANIL	"Danil"
#define OLYA	"Olya"
#define SLAVA	"Slava"
#define ANN		"Ann"
#define NIKITA	"Nikita"

#define MAX_LINE	101

#define DEBUG(x, y)	do{printf("DEBUG:: %s = " #y"\n", #x, x);}while(0);
#define DEBUG_STR(str, len)	for(int i = 0; i<len; i++){ printf("%c", str[i]); }printf("\n");

int main(void){

	char contest[MAX_LINE];
	int found_friends = 0, index = 0;
	friend_t friends[5];
	int len = 0;

	friends[0].name = DANIL;
	friends[1].name = OLYA;
	friends[2].name = SLAVA;
	friends[3].name = ANN;
	friends[4].name = NIKITA;

	for(index = 0; index < 5; index++){

		friends[index].name_len = strlen(friends[index].name);

	}

	scanf("%s", contest);
	len = strlen(contest);

	for(index = 0; index < 5; index++){

		found_friends += CountStr(contest, friends[index].name, len, friends[index].name_len);

		if(found_friends > 1){
			break;
		}
	}

	if(found_friends == 1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

int StrCompare(char * str_a, char * str_b, int len_a, int len_b){

	int res = 0, index = 0;

	if(len_a != len_b){

		res = len_a - len_b;

	}else{

		for(index = 0; index < len_a; index++){

			if(str_a[index] != str_b[index]){

				res += str_a[index] - str_b[index];
				break;

			}	// end if str_a[index] != str_b[index]

		}	// end for index = 0; index < len_a; index++

	}	// end if len_a != len_b

	return res;
}

bool_t ContainsStr(char * string, char * sub_str, int str_len, int sub_len){

	int index = 0;

	if(str_len == sub_len){

		// if both strings are equal, return True
		if(StrCompare(string, sub_str, str_len, sub_len) == 0){

			return True;

		}	// end if(StrCompare(string, sub_str, str_len, sub_len) == 0)

	}else if( sub_len < str_len ){

		for(index = 0; index < str_len - sub_len + 1; index++){

			if( StrCompare(&string[index], sub_str, sub_len, sub_len ) == 0 ){

				return True;

			}	// end if( StrCompare(&string[index], sub_str, sub_len, sub_len ) == 0 )

		}	// end for(index = 0; index < str_len - sub_len; index++)

	}else{

		// do nothing

	}	// end if(str_len == sub_len)

	return False;
}

int CountStr(char * string, char * sub_str, int str_len, int sub_len){

	int count = 0, index = 0;

	for(index = 0; index <= str_len - sub_len; index++){

		if( StrCompare( &string[index], sub_str, sub_len, sub_len ) == 0){
			count++;
		}

	}

	return count;

}

#include<stdio.h>
#include<string.h>
int main()
{
	char a[16]="Danil";
	char b[15]="Olya";
	char c[16]="Slava";
	char d[14]="Ann";
	char e[17]="Nikita";
	int la=5,lb=4,lc=5,ld=3,le=6;
	char s[103]={0};
	scanf("%s",s);
	char * u=NULL;
	char * v=NULL;
	char * w=NULL;
	char * x=NULL;
	char * y=NULL;
	char * u1=NULL;
	char * v1=NULL;
	char * w1=NULL;
	char * x1=NULL;
	char * y1=NULL;
	u=strstr(s,a);
	v=strstr(s,b);
	w=strstr(s,c);
	x=strstr(s,d);
	y=strstr(s,e);
	if(u!=NULL)u1=strstr(u+1,a);
	if(v!=NULL)v1=strstr(v+1,b);
	if(w!=NULL)w1=strstr(w+1,c);
	if(x!=NULL)x1=strstr(x+1,d);
	if(y!=NULL)y1=strstr(y+1,e);

	int l=0,m=0,n=0,o=0,p=0;
	if(u!=NULL)l=1;
	if(v!=NULL)m=1;
	if(w!=NULL)n=1;
	if(x!=NULL)o=1;
	if(y!=NULL)p=1;
	if(u1!=NULL)l+=1;
	if(v1!=NULL)m+=1;
	if(w1!=NULL)n+=1;
	if(x1!=NULL)o+=1;
	if(y1!=NULL)p+=1;

	if(l+m+n+o+p==1)printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include <stdio.h>
#define MAX 100

int main(){
	char in[MAX],index;
	int matcht=0;
	char temp [5]="DOSAN";
	char friends[5][7]={"Danil1 ","Olya1  ","Slava1 ","Ann1   ","Nikita1"};
	for(int i=0;;i++){
		scanf("%c",&in[i]);
		if(in[i]=='\n'){
			in[i]='\0';
			break;
		}
	}
	for(int i=0;;i++){
		if(in[i]=='\0')
			break;
		for(index=0;index<5;index++)
			if(in[i]==temp[index])
				break;
		if(index<5)
			for(int j=0;j<7;j++){
				if(friends[index][j]=='1'){
					matcht++;
					break;
				}
				if(friends[index][j]!=in[i+j])
					break;
			}
	}
		if(matcht==0||matcht>1)
		printf("NO");
	else
		printf("YES");

	return 0;
}

#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[200];
	int cnt = 0;
	scanf("%s", str);

	char* p;

	p = str;
	while ((p = strstr(p, "Danil")) != NULL) { cnt++; p++; }
	p = str;
	while ((p = strstr(p, "Olya")) != NULL) { cnt++; p++; }
	p = str;
	while ((p = strstr(p, "Slava")) != NULL) { cnt++; p++; }
	p = str;
	while ((p = strstr(p, "Ann")) != NULL) { cnt++; p++; }
	p = str;
	while ((p = strstr(p, "Nikita")) != NULL) { cnt++; p++; }

	if (cnt != 1) printf("NO");
	else printf("YES");

	return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
    char s [101];
    int c=0;
    scanf("%s",s);
    if (strstr(s,"Danil")){
        c++;
        }
        if (strstr(s,"Olya")){
            c++;
        }
        if (strstr(s,"Slava")){
            c++;
        }
        if (strstr(s,"Ann")){
            c++;
        }
         if (strstr(s,"Nikita")){
            c++;
        }
        if (c==1){
            printf ("YES");
        }
        else {
            printf ("NO");
        }
}

#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
 int i,j,k,l1,l2,c=0;
 scanf("%s",&s);
strlen(s);
 for(i=0;i<5;i++)
   {
   	l2=strlen(name[i]);
   	for(j=0;j<l1-l2+1;j++)
   	{
   		int f=1;
   		for(k=0;k<l2;k++) if(s[j+k] = name[i][k]) f=0;

   		if(f) c++;
	   }
   }

if(c==1) printf("YES");
else printf("NO");

}

#include<stdio.h>
#include<string.h>
int main(){

   char a[200];
   int b=0,ck=0,ck1=0,ck2=0,ck3=0,ck4=0;
   gets(a);
   if(strstr(a,"Danil")!=0){
    ck=1;
    }
     if(strstr(a,"Olya")!=0){
    ck1=1;
    }
     if(strstr(a,"Slava")!=0){
    ck2=1;
    }
    if(strstr(a,"Ann")!=0){
    ck3=1;
    }
      if(strstr(a,"Nikita")!=0){
    ck4=1;
    }
   // printf("%d",b);
   b=ck+ck1+ck2+ck3+ck4;
   if(b==1){
   printf("YES");
   }
   else{
   printf("NO");
   }
return 0;
   }
//http://codeforces.com/problemset/problem/877/A

#include <stdio.h>
#include <string.h>

int find_word(char s[],char name[]){
	int slen,nlen,i,j,count=0;
	slen=strlen(s);
	nlen=strlen(name);
	for(i=0;i<slen;i++)
	{
		if(s[i]==name[0])
		{
			for(j=0;j<nlen;j++)
			{
				if(s[i+j]!=name[j])
				{
					break;
				}
			}
			if(j==nlen)
			count++;
			i+=j;
		}
	}
	return count;
}

int main(void) {
	char s[1000];
	int count=0;
	scanf("%s",s);
	count+=find_word(s,"Danil");
	count+=find_word(s,"Olya");
	count+=find_word(s,"Slava");
	count+=find_word(s,"Ann");
	count+=find_word(s,"Nikita");
	if(count==1)printf("YES\n");
	else printf("NO\n");

	return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    char name[][7] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
    char str[101];
    int cnt = 0;
    scanf("%s", str);
    int len = strlen(str);
    for(int i = 0; i < 5; ++i) {
        for(int j = 0; j < len; ++j) {
            if(strstr(str + j, name[i]) != NULL) {
                ++cnt;
            }
        }
    }
    puts(cnt == 1 ? "YES" : "NO");
    return 0;
}

#include "stdio.h"
#include "string.h"

int StringFind(const char *pSrc, const char *pDst)
{
    int i, j;
    int num = 0;
    for (i=0; pSrc[i]!='\0'; i++)
    {
        if(pSrc[i]!=pDst[0])
            continue;
        j = 0;
        while(pDst[j]==pSrc[i+j])
        {
            j++;
        }
        if(j==strlen(pDst))
        {
            num++;
            i += j;
        }
    }
    if(num>0)
        return num;
    else
        return 0;
}

int main()
{
    char s[100];
    while(scanf("%s",&s)!=EOF)
    {
        int result = 0;
        result += StringFind(s,"Danil");
        result += StringFind(s,"Olya");
        result += StringFind(s,"Slava");
        result += StringFind(s,"Nikita");
        result += StringFind(s,"Ann");
        if(result==1)
            printf("YES\n");
        else
            printf("NO\n");
    }
}

#include <stdio.h>
#include <string.h>

int main()
{
    char name[][7] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
    char str[101];
    int cnt = 0;
    scanf("%s", str);
    for(int i = 0; i < 5; ++i) {
        if(strstr(str, name[i]) != NULL) {
            ++cnt;
        }
    }
    puts(cnt == 1 ? "YES" : "NO");
    return 0;
}

#include <stdio.h>

int checkD(char *n, int l, int i)
{
	if(n[i+1]=='a' && n[i+2]=='n' && n[i+3]=='i' && n[i+4]=='l')
		return 1;
	else
		return 0;
}

int checkO(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='y' && n[i+3]=='a')
		return 1;
	else
		return 0;
}

int checkS(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='a' && n[i+3]=='v' && n[i+4]=='a')
		return 1;
	else
		return 0;
}

int checkA(char *n, int l, int i)
{
	if(n[i+1]=='n' && n[i+2]=='n')
		return 1;
	else
		return 0;
}

int checkN(char *n, int l, int i)
{
	if(n[i+1]=='i' && n[i+2]=='k' && n[i+3]=='i' && n[i+4]=='t'&& n[i+5]=='a')
		return 1;
	else
		return 0;
}

int main()
{
	char n[99999];

	int l=0,i,x=0,count=0;

	gets(n);

	while(n[l]) l++;

	for(i=0;i<l;i++)
	{
		if(n[i]=='D')
		{
			x=checkD(n,l,i);
		}
		else if(n[i]=='O')
		{
			x=checkO(n,l,i);
		}
		else if(n[i]=='S')
		{
			x=checkS(n,l,i);
		}
		else if(n[i]=='A')
		{
			x=checkA(n,l,i);
		}
		else if(n[i]=='N')
		{
			x=checkN(n,l,i);
		}
		if(x==1)
		{
			count++;
		}

		continue;
	}
	if(count==1) printf("YES\n");
	else printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
int i,b,c;int flag,j;flag=0;b=c=0;char s[101],*ptr;int p[5]={0,0,0,0,0};
scanf("%s",&s);
char *a[5]={"Danil","Olya","Slava","Ann","Nikita"};

for(i=0;i<5;i++)
{

ptr=strstr(s,a[i]);
if(ptr!=NULL){
p[i]++;
/*for(j=0;j<strlen(a[i]);j++)
	ptr++;
strcpy(s,ptr);

i=i-1;*/
}

else
continue;

}

for(i=0;i<5;i++)
{
if(p[i]==0)
b++;

else
{
if(p[i]>1)
{
flag=1;
break;
}

if(p[i]==1)
c++;
}}
//printf("%d\n",c);
if((b==5)||(flag==1)||(c>1))
printf("NO\n");
else
printf("YES\n");
exit(0);
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
int i,b,c,z,t;int flag,j;flag=0;b=c=0;char s[101],*ptr;int p[5]={0,0,0,0,0};
scanf("%s",&s);
char *a[5]={"Danil","Olya","Slava","Ann","Nikita"};

for(i=0;i<5;i++)
{

ptr=strstr(s,a[i]);
if(ptr!=NULL){
p[i]++;

for(z=0;z<strlen(s);z++)
if(s[z]==*a[i]){
t=z;break;}

for(j=t+strlen(a[i]);j<strlen(s);j++){
s[t]=s[j];t++;}
s[t]='\0';

i=i-1;
}

else
continue;

}

for(i=0;i<5;i++)
{
if(p[i]==0)
b++;

else
{
if(p[i]>1)
{
flag=1;
break;
}

if(p[i]==1)
c++;
}}
//printf("%d\n",c);
if((b==5)||(flag==1)||(c>1))
printf("NO\n");
else
printf("YES\n");
exit(0);
}

#include <stdio.h>

int checkD(char *n, int l, int i)
{
	if(n[i+1]=='a' && n[i+2]=='n' && n[i+3]=='i' && n[i+4]=='l')
		return 1;
	else
		return 0;
}

int checkO(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='y' && n[i+3]=='a')
		return 1;
	else
		return 0;
}

int checkS(char *n, int l, int i)
{
	if(n[i+1]=='l' && n[i+2]=='a' && n[i+3]=='v' && n[i+4]=='a')
		return 1;
	else
		return 0;
}

int checkA(char *n, int l, int i)
{
	if(n[i+1]=='n' && n[i+2]=='n')
		return 1;
	else
		return 0;
}

int checkN(char *n, int l, int i)
{
	if(n[i+1]=='i' && n[i+2]=='k' && n[i+3]=='i' && n[i+4]=='t'&& n[i+5]=='a')
		return 1;
	else
		return 0;
}

int main()
{
	char n[99999];

	int l=0,i,x=0;

	gets(n);

	while(n[l]) l++;

	for(i=0;i<l;i++)
	{
		if(n[i]=='D')
		{
			x=checkD(n,l,i);
		}
		else if(n[i]=='O')
		{
			x=checkO(n,l,i);
		}
		else if(n[i]=='S')
		{
			x=checkS(n,l,i);
		}
		else if(n[i]=='A')
		{
			x=checkA(n,l,i);
		}
		else if(n[i]=='N')
		{
			x=checkN(n,l,i);
		}
		if(x==1)
		{
			printf("YES\n");
			return 0;
		}
		else
		{
			continue;
		}
	}
	printf("NO\n");
	return 0;
}

#include<stdio.h>
#include<string.h>

int main()
{
    int i, f = 0;
    char name[100000], names[][7] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
    scanf("%s", name);
    for(i=0; i<5; i++){
        if(strstr(name, names[i]))f++;
    }
    printf("%s", (f>1||f==0)?"NO":"YES");
    return 0;
}

// http://codeforces.com/contest/877/problem/A

#include <stdio.h>
#include <string.h>

typedef enum {
	False,
	True
} bool_t;

typedef struct{
	char * name;
	int name_len;
} friend_t;

int StrCompare(char * str_a, char * str_b, int len_a, int len_b);
bool_t ContainsStr(char * string, char * sub_str, int str_len, int sub_len);

#define DANIEL	"Danil"
#define OLYA	"Olya"
#define SLAVA	"Slava"
#define ANN		"Ann"
#define NIKITA	"Nikita"

#define MAX_LINE	101

#define DEBUG(x, y)	do{printf("DEBUG:: %s = " #y"\n", #x, x);}while(0);
#define DEBUG_STR(str, len)	for(int i = 0; i<len; i++){ printf("%c", str[i]); }printf("\n");

int main(void){

	char contest[MAX_LINE];
	int found_friends = 0, index = 0;
	friend_t friends[5];
	int len = 0;

	friends[0].name = DANIEL;
	friends[1].name = OLYA;
	friends[2].name = SLAVA;
	friends[3].name = ANN;
	friends[4].name = NIKITA;

	for(index = 0; index < 5; index++){

		friends[index].name_len = strlen(friends[index].name);

	}

	scanf("%s", contest);
	len = strlen(contest);

	for(index = 0; index < 5; index++){

		if( ContainsStr(contest, friends[index].name, len, friends[index].name_len) == True ){
			found_friends++;
		}
	}

	if(found_friends == 1){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

int StrCompare(char * str_a, char * str_b, int len_a, int len_b){

	int res = 0, index = 0;

	if(len_a != len_b){

		res = len_a - len_b;

	}else{

		for(index = 0; index < len_a; index++){

			if(str_a[index] != str_b[index]){

				res += str_a[index] - str_b[index];
				break;

			}	// end if str_a[index] != str_b[index]

		}	// end for index = 0; index < len_a; index++

	}	// end if len_a != len_b

	return res;
}

bool_t ContainsStr(char * string, char * sub_str, int str_len, int sub_len){

	int index = 0;

	if(str_len == sub_len){

		// if both strings are equal, return True
		if(StrCompare(string, sub_str, str_len, sub_len) == 0){

			return True;

		}	// end if(StrCompare(string, sub_str, str_len, sub_len) == 0)

	}else if( sub_len < str_len ){

		for(index = 0; index < str_len - sub_len + 1; index++){

			if( StrCompare(&string[index], sub_str, sub_len, sub_len ) == 0 ){

				return True;

			}	// end if( StrCompare(&string[index], sub_str, sub_len, sub_len ) == 0 )

		}	// end for(index = 0; index < str_len - sub_len; index++)

	}else{

		// do nothing

	}	// end if(str_len == sub_len)

	return False;
}

#include<stdio.h>
int main()
{
int y,b,r,total;
scanf("%d",&y);
scanf("%d",&b);
scanf("%d",&r);
if(y==r&&y==b)
	total=r+(r-1)+(r-2);
else if(y<=b&&(y+1)<r)
	total=y+(y+1)+(y+2);
else if(b<=y&&b<=r)
	total=b+(b+1)+(b-1);
else if((r-1)<=y&&r<=b)
	total=r+(r-1)+(r-2);
 printf("%d",total);
return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
long long i,b,c;int flag,j;flag=0;b=c=0;char s[101],*ptr;int p[5]={0,0,0,0,0};
scanf("%s",&s);
char *a[5]={"Danil","Olya","Slava","Ann","Nikita"};

for(i=0;i<5;i++)
{

ptr=strstr(s,a[i]);
if(ptr!=NULL){
p[i]++;
for(j=0;j<strlen(a[i]);j++)
	ptr++;
strcpy(s,ptr);

i=i-1;
}

else
continue;

}

for(i=0;i<5;i++)
{
if(p[i]==0)
b++;

else
{
if(p[i]>1)
{
flag=1;
break;
}

if(p[i]==1)
c++;
}}

if((b==5)||(flag==1)||(c>1))
printf("NO\n");
else
printf("YES\n");
exit(0);
}

#include<stdio.h>
#include<string.h>
int main(){
   char a[50],b[50];
   scanf("%s",a);
   int k,j,l;
   if(strlen(a)%2==0){
      j=(strlen(a)/2)-1;
      l=j+1;
   }
   else{
      j=(strlen(a)/2);
      l=j+1;
   }
   for(k=0;k<strlen(a);k++){
      if(k%2==0){
         b[k]=a[j];
         j--;
      }
      else{
         b[k]=a[l];
         l++;
      }
   }
   b[k]='\0';
   printf("%s",b);
   return 0;
}

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define uLL unsigned long long
#define uL unsigned int
#define uC unsigned char

#define NODES 1000007
#define NNNN 200007
#define MemoryStackTotal 10000000
#define error 1e-8
static unsigned char BakaMemoryStack[MemoryStackTotal];static unsigned char *MemoryStackTop=BakaMemoryStack;void *Allocates(unsigned long size){MemoryStackTop+=size;return MemoryStackTop-size;}void Releases(unsigned long size){MemoryStackTop-=size;if (MemoryStackTop<BakaMemoryStack) {MemoryStackTop=BakaMemoryStack;}}
void mergesort(long *ds,int (*compare)(long a,long b),long size){long i,j,k,s,b,e;long *ms=(long*)Allocates(sizeof(long)*(size+1));	for (k=1;k<=size;k=k<<1)	{		for (i=1;i+k<=size;i+=k<<1)		{			s=i;b=i+k;e=b+k-1;			if (e>size) {e=size;}			for (j=1;(s<i+k)&&(b<=e);j++)			{				if (compare(ds[s],ds[b])<=0)				{					ms[j]=ds[s++];				}				else				{					ms[j]=ds[b++];				}			}			for (b=i+k-1;b>=s;b--)			{				ds[e--]=ds[b];			}			for (b=1;b<j;b++)			{				ds[i+b-1]=ms[b];			}		}	}	Releases(sizeof(long)*(size+1));}
void swap(uL *a,uL *b){*a=*a^*b;*b=*a^*b;*a=*a^*b;}void swap64(uLL *a,uLL *b){*a=*a^*b;*b=*a^*b;*a=*a^*b;}uL bsf(uL a){__asm__ __volatile__("bsfl %0,%0":"+r"(a));return a;}uL bsr(uL a){__asm__ __volatile__("bsrl %0,%0":"+r"(a));return a;}uL imin(uL a,uL b){__asm__ __volatile__("cmpl %0,%1\n""cmovll %1,%0":"+&r"(a):"g"(b));return a;}uL imax(uL a,uL b){__asm__ __volatile__("cmpl %0,%1\n""cmovgl %1,%0":"+&r"(a):"g"(b));return a;}uL min(uL a,uL b){__asm__ __volatile__("cmpl %0,%1\n""cmovbl %1,%0":"+&r"(a):"g"(b));return a;}uL max(uL a,uL b){__asm__ __volatile__("cmpl %0,%1\n""cmoval %1,%0":"+&r"(a):"g"(b));return a;}
void print(long *a,long size){long i;for (i=0;i<size;i++){printf("%ld ",a[i]);}printf("%ld\n",a[i]);}void printll(LL *a,long size){long i;for (i=0;i<size;i++){printf("%lld ",a[i]);}printf("%lld\n",a[i]);}
void mergesort2(LL *ds,long size) {long i,j,k,s,b,e;LL *ms=(LL*)Allocates(sizeof(uLL)*(size+1));	for (k=1;k<=size;k=k<<1)	{		for (i=1;i+k<=size;i+=k<<1)		{			s=i;b=i+k;e=b+k-1;			if (e>size) {e=size;}			for (j=1;(s<i+k)&&(b<=e);j++)			{				if (ds[s]<=ds[b])				{					ms[j]=ds[s++];				}				else				{					ms[j]=ds[b++];				}			}			for (b=i+k-1;b>=s;b--)			{				ds[e--]=ds[b];			}			for (b=1;b<j;b++)			{				ds[i+b-1]=ms[b];			}		}	}	Releases(sizeof(long)*(size+1));}

char word[][10]={{0},"Danil","Olya","Slava","Ann","Nikita"};
char str[100000];
int main()
{
	long i,j,k,a,b,c,ans;
	ans=0;
	while (gets(str)!=NULL) {if (isalpha(*str)!=0) {break;}}
	for (j=1;j<=5;j++)
	{
		for (k=0,i=0;str[i]!='\0';i++)
		{
			if (word[j][k]==str[i]) {k++;} else {k=0;}
			if (word[j][k]=='\0') {ans++;k=0;}
		}
	}
	if (ans==1)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void removeSubstring(char *s,const char *remove)
{
char * aux =strstr(s,remove) ;
int n=strlen(remove);
int pos=s-aux ;
for (int i=0;i<n;i++)
s[i+pos]='*' ;
}

main()
{ char f[100] ; const char* f1="Danil", *f3="Olya", *f2="Ann", *f4="Slava", *f5="Nikita";
	scanf("%s",&f);
	int i=0;
	for (int j=0;j<2;j++){
	if (strstr(f,f1)){i=i+1; removeSubstring(f,"Danil");}
	if  (strstr(f,f2)){i=i+1; removeSubstring(f,"Ann");}
	if  (strstr(f,f3)){i=i+1; removeSubstring(f,"Olya");}
	if  (strstr(f,f4)){i=i+1; removeSubstring(f,"Slava");}
	if  (strstr(f,f5)){i=i+1; removeSubstring(f,"Nikita");};

}
if (i!=1)printf("NO"); else printf("YES");
}

#include <stdio.h>

const char *name[5] = {"Danil","Olya","Slava","Ann","Nikita"};
int main()
{
	char s[105];
	int cnt = 0;
	gets(s);
	for (int i = 0; i < 5; i++)
	{
		char *p = s;
		while (strstr(p, name[i]) != NULL)
		{
			cnt++;
			p = p + strlen(name[i]);
		}
	}
	puts(cnt == 1 ? "YES" : "NO");
	return 0;
}

#include <stdio.h>
int main()
{
	int n,k=0,b,e,c=-1;
	scanf("%d %d %d",&n,&b,&e);
	for(int i=n;i>b;i--)
	{
		c=c+1;
		if(c<=e)
		{
			k=k+1;
		}
	}

	printf("%d",k);
return 0;
}

#include "stdio.h"
#include "string.h"

int StringFind(const char *pSrc, const char *pDst)
{
    int i, j;
    for (i=0; pSrc[i]!='\0'; i++)
    {
        if(pSrc[i]!=pDst[0])
            continue;
        j = 0;
        while(pDst[j]!='\0' && pSrc[i+j]!='\0')
        {
            j++;
            if(pDst[j]!=pSrc[i+j])
            break;
        }
        if(pDst[j]=='\0')
            return 1;
    }
    return 0;
}

int main()
{
    char s[100];
    while(scanf("%s",&s)!=EOF)
    {
        if(StringFind(s,"Danil")||StringFind(s,"Olya")||StringFind(s,"Slava")||StringFind(s,"Nikita")||StringFind(s,"Ann"))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

#include<stdio.h>
#include<string.h>
int main(){

   char a[200];
   int b=0;
   gets(a);
   if(strstr(a,"Danil")!=0){
    b++;
    }
     if(strstr(a,"Olya")!=0){
    b++;
    }
     if(strstr(a,"Slava")!=0){
    b++;
    }
    if(strstr(a,"Ann")!=0){
    b++;
    }
      if(strstr(a,"Nikita")!=0){
    b++;
    }
   // printf("%d",b);
   if(b==1){
   printf("YES");
   }
   else{
   printf("NO");
   }
return 0;
   }

#include <stdio.h>
#include <stdlib.h>

int main()
{

char string[101];
scanf("%s",string);
int count =0;
for(int i =0 ;i<101;i++){
    if(string[i]!='\0'){
        if(string[i]=='A'&&string[i+1]=='n'&&string[i+2]=='n'){
            count++;
        }
        if(string[i]=='S'&&string[i+1]=='l'&&string[i+2]=='a'&&string[i+3]=='v'&&string[i+4]=='a'){
            count++;

        }
        if(string[i]=='N'&&string[i+1]=='i'&&string[i+2]=='k'&&string[i+3]=='i'&&string[i+4]=='t'&&string[i+5]=='a'){
            count++;
        }
        if(string[i]=='O'&&string[i+1]=='l'&&string[i+2]=='y'&&string[i+3]=='a'){
            count++;
        }
        if(string[i]=='O'&&string[i+1]=='l'&&string[i+2]=='y'&&string[i+3]=='a'){
            count++;
        }
        if(string[i]=='D'&&string[i+1]=='a'&&string[i+2]=='n'&&string[i+3]=='i'&&string[i+4]=='l'){
            count++;

        }
    }
}

if(count==1){
    printf("YES");
}else{
printf("NO");
}
    return 0;
}

#include <stdio.h>
#include<string.h>
int main()
{
    char c[100];
    char d[100];

    char a1[] =  "Danil"; int b1 = 0;
    char a2[] =  "Olya"; int b2 = 0;
    char a3[] =  "Slava"; int b3 = 0;
    char a4[] =  "Ann"; int b4 = 0;
    char a5[] =  "Nikita"; int b5 = 0;
    scanf("%s",c);
    int len = strlen(c);
    int j = 0;
    for(int i = 0; i<=len;i++)
    {   if(i==0)
            goto A ;
        int q = c[i];
        if((c[i]=='_')||c[i]=='\0')
        {
            j=0 ;
            if(strcmp(a1,d)==0) b1++;
            else if(strcmp(a2,d)==0) b2++;
            else if(strcmp(a3,d)==0) b3++;
            else if(strcmp(a4,d)==0) b4++;
            else if(strcmp(a5,d)==0) b5++;
            for(int h = 0;h<100;h++)
                d[h]='\0';

            continue;
        }
        else if((q>=65)&&(q<=90)&&(c[i-1]!='_'))
        {
            j=0 ;
            if(strcmp(a1,d)==0) b1++;
            else if(strcmp(a2,d)==0) b2++;
            else if(strcmp(a3,d)==0) b3++;
            else if(strcmp(a4,d)==0) b4++;
            else if(strcmp(a5,d)==0) b5++;
            for(int h = 0;h<100;h++)
                d[h]='\0';

            continue;
        }
        else
        {
            A:
            d[j] = c[i];
            j++;
        }
    }
    int k[5] = {b1,b2,b3,b4,b5};
    int check = 0;
    int ch = 0;
    for(int i = 0; i<5; i++)
    {
        if(k[i]>1)
        {
            check = 1;
            break;
        }

        else if(k[i]==1)
            ch++;
    }

    if((ch==1)&&(check==0))
        printf("YES");
    else
        printf("NO");
}

#include <stdio.h>
#include <string.h>

int main()
{
    char name[100];
    scanf("%s", name);
    if( (strstr(name, "Danil")!=NULL) ||
       (strstr(name, "Olya")!=NULL) ||
       (strstr(name, "Ann")!=NULL)||
       (strstr(name, "Nikita")!=NULL) ||
       (strstr(name, "Slava")!=NULL) )
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

#include<stdio.h>
#include<string.h>

int main()
{
    int i,j,cont=0,tam,tam1;
    char frase[105],nome1[5]="Danil",nome2[4]="Olya",nome3[5]="Slava",nome4[3]="Ann",nome5[6]="Nikita";
    scanf("%s",frase);
    tam=strlen(frase);
    for(i=0;i<tam;i++)
    {
        if(frase[i] == 'D')
        {
            if(frase[i+1] == 'a' && frase[i+2] == 'n' && frase[i+3] == 'i' && frase[i+4] == 'l')
                cont++;
        }
        else if(frase[i] == 'O')
        {
            if(frase[i+1] == 'l' && frase[i+2] == 'y' && frase[i+3] == 'a')
                cont++;
        }
        else if(frase[i] == 'S')
        {
            if(frase[i+1] == 'l' && frase[i+2] == 'a' && frase[i+3] == 'y' && frase[i+4] == 'a')
                cont++;
        }
        else if(frase[i] == 'A')
        {
            if(frase[i+1] == 'n' && frase[i+2] == 'n')
                cont++;
        }
        else if(frase[i] == 'N')
        {
            if(frase[i+1] == 'i' && frase[i+2] == 'k' && frase[i+3] == 'i' && frase[i+4] == 't' && frase[i+5] == 'a')
                cont++;
        }
    }
    if(cont == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

/* 1519485265000 */

/*
 * 6.10.c
 *
 * Copyright 2019 HP <HP@DESKTOP-L2C0F23>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
	int check(char[],char[]);
int main(){
char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
 int i,j,k,l1,l2,c=0;
 scanf("%s",&s);
l1=strlen(s);
 for(i=0;i<5;i++)
   {
   	l2=strlen(name[i]);
   	for(j=0;j<l1-l2+1;j++)
   	{
   		int f=1;
   		for(k=0;k<l2;k++) if(s[j+k] != name[i][k]) f=0;

   		if(f) c++;
	   }
   }

if(c==1) printf("YES");
else printf("NO");

}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int cmp(const void *a,const void *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    char a[105],b[105][105];
    scanf("%s",a);
    int n=strlen(a),i,j=0,k;
    char c[5][7]={"Danil","Olya","Slava","Ann","Nikita"};
    int count=0;
    for(i=0;i<5;i++)
    {
        if(strstr(a,c[i])!=NULL)
            count++;
    }
    if(count==1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}

#include<stdio.h>
#include<string.h>
int main ()
{
    char s [101];
    int i,c=0;
    scanf("%s",s);
    for (i=0;i,i<strlen(s);i++){
    if (strstr(s,"Danil")){
        c++;
        }
        if (strstr(s,"Olya")){
            c++;
        }
        if (strstr(s,"Slava")){
            c++;
        }
        if (strstr(s,"Ann")){
            c++;
        }
         if (strstr(s,"Nikita")){
            c++;
        }
    }
        if (c==1){
            printf ("YES");
        }
        else {
            printf ("NO");
        }
}

#include <stdio.h>
int main()
{	int n,m=1,i;
	scanf("%d",&n);
	for(i=1;i<=n-1;i++)
	{	m=m+i;
		if(m>n)
		m=m-n;
		printf("%d ",m);
	}
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include<string.h>

#define problemNameSize 100

int main()
{
    char problemName [problemNameSize];

    scanf("%s",problemName);
    int i,n=5,cnt=0;
    char friends[5][7] = {"Danil", "Olya", "Slava", "Ann", "Nikita"};
    char* strAfter = problemName;

    for (i = 0; i < n; i++)
    {
        if(strstr(strAfter, friends[0]) != NULL) {

                cnt++;
                strAfter = strAfter + strlen(friends[0]);

        } else if(strstr(strAfter, friends[1]) != NULL) {

                cnt++;
                strAfter = strAfter + strlen(friends[1]);

        } else if(strstr(strAfter, friends[2]) != NULL) {

                cnt++;
                strAfter = strAfter + strlen(friends[2]);

        } else if(strstr(strAfter, friends[3]) != NULL) {

                cnt++;
                strAfter = strAfter + strlen(friends[3]);

        } else if(strstr(strAfter, friends[4]) != NULL) {

                cnt++;
                strAfter = strAfter + strlen(friends[4]);

        }
    }
    //printf("%d \n",cnt);
        if(cnt == 1)
        {
            printf("YES");
        } else {
            printf("NO");
        }
    //printf("%I64d %I64d \n",sasha,lina);

    return 0;
}

#include <stdio.h>
#include <string.h>
char buffer[101];
int verifica(char s[]){
	if( (strstr(s,"Danil"))&&(!strstr(s,"Olya"))&&(!strstr(s,"Slava"))&&(!strstr(s,"Ann"))&&(!strstr(s,"Nikita")) ){
		return 1;
	}
	if( (!strstr(s,"Danil"))&&(strstr(s,"Olya"))&&(!strstr(s,"Slava"))&&(!strstr(s,"Ann"))&&(!strstr(s,"Nikita")) ){
		return 1;
	}
	if( (!strstr(s,"Danil"))&&(!strstr(s,"Olya"))&&(strstr(s,"Slava"))&&(!strstr(s,"Ann"))&&(!strstr(s,"Nikita")) ){
		return 1;
	}
	if( (!strstr(s,"Danil"))&&(!strstr(s,"Olya"))&&(!strstr(s,"Slava"))&&(strstr(s,"Ann"))&&(!strstr(s,"Nikita")) ){
		return 1;
	}
	if( (!strstr(s,"Danil"))&&(!strstr(s,"Olya"))&&(!strstr(s,"Slava"))&&(!strstr(s,"Ann"))&&(strstr(s,"Nikita")) ){
		return 1;
	}

	return 0;
}

int main(void) {
	scanf("%s",buffer);
	printf( "%s",verifica(buffer)?"YES":"NO");
	return 0;
}

/* 1514695902196 */

#include<stdio.h>
#include<string.h>

int search(char *pat, char *txt){
    int i,j,count=0;
    int M = strlen(pat);
    int N = strlen(txt);
    for(i = 0; i <= N - M; i++){
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;
        if (j == M)
            count++;
    }
    return count;
}
int main(){
    int total,i;
    char str[100];
    char friends[5][10] = {"Danil","Olya","Slava","Ann","Nikita"};
    scanf("%s",str);
    for(i=0; i<5; i++)
        total = search(friends[i], str);
    if(total == 1) printf("YES\n");
    else printf("NO\n");
   return 0;
}

#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[101];
    int count=0;
    gets(str);
    puts(strstr(str,"Nikita"));
    if ((strstr(str,"Nikita")) && !(strstr(strstr(str,"Nikita")+1,"Nikita"))) ++count;
    if ((strstr(str,"Danil")) && !(strstr(strstr(str,"Danil")+1,"Danil"))) ++count;
    if ((strstr(str,"Olya")) && !(strstr(strstr(str,"Olya")+1,"Olya"))) ++count;
    if ((strstr(str,"Slava")) && !(strstr(strstr(str,"Slava")+1,"Slava"))) ++count;
    if ((strstr(str,"Ann")) && !(strstr(strstr(str,"Ann")+1,"Ann"))) ++count;
    if (count==1) printf("YES");
    else printf("NO");
    return 0;
}

#include <stdio.h>

int main(void)
{
    int n,i;
    scanf("%d",&n);
    printf("%d\n",n+n/2);
    for (i=2;i<=n;i+=2) printf("%d ",i);
    for (i=1;i<=n;i+=2) printf("%d ",i);
    for (i=2;i<=n;i+=2) printf("%d ",i);
    return 0;
}

#include<stdio.h>
#include<string.h>
int main(){
char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
int f=1,i,j,k,ql,nl;
 scanf("%s",&s);
 ql=strlen(s);
 for(i=0;i<5;i++)
   {
   	nl=strlen(name[i]);
   	for(j=0;j<ql-nl+1;j++)
   	{
   	  for(k=0;k<nl;k++)
                 { if(s[j+k] != name[i][k])
                   { f=0;}
                 }
        }
   }

if(f)
 {printf("YES");}
else
 {printf("NO");}

}

#include <stdio.h>
int main()
{
	long long int n,k=0;
	int d;
	scanf("%lld",&n);
	{
		while(n!=0)
		{

			d=n%10;
			if(d==4||d==7)
			{
				k++;
			}
			n=n/10;
		}
	}
	if((k==4 || k==7)&&k!=0)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}

#include <stdio.h>
#include <math.h>
#include <time.h>

int main(){
    char mystring[5001];
    scanf("%s", mystring);
    int ct,length;
    for(ct = 0 ; ct < 5001 ; ct++){
        if(mystring[ct] == '\0'){
            length = ct;
            break;
        }
    }
    int blocks[5005] = {0};
    int changes = 0;
    int counter = 0;
    char currentstage = 'a';
    for(ct = 0 ; ct < length ; ct++){
        if(mystring[ct] != currentstage){
            blocks[changes] = counter;
            counter = 1;
            changes++;
            currentstage = mystring[ct];
        }else{
            counter++;
        }
    }
    blocks[changes] = counter;
    if(changes <= 2){
        printf("%d", length);
        return 0;
    }
    //printf("%d\t%d\t%d\t%d\t\t%d\n", blocks[0], blocks[1], blocks[2], blocks[3], changes);
    int max = 0, ct2, ct3;
    for(ct = 0 ; ct  <= changes + 2  ; ct+=2){
        for(ct2 = ct + 1 ; ct2  <= changes + 2 ; ct2+=2){
            for(ct3 = ct2 + 1 ; ct3 <= changes + 2; ct3 += 2){
                if(blocks[ct3] + blocks[ct2] + blocks[ct] > max){
                    max = blocks[ct3] + blocks[ct2] + blocks[ct];
                }
            }
        }
    }

    printf("%d", max);

}


#include <stdio.h>

#define rep(i,n) for(i=0;i<n;i++)
#define N 404

int x, y, n, d, vx[20], vy[20], mem[N][N];

int rec( int a, int b )
{
	if( a*a + b*b > d*d ) return 1;
	int *ans = &mem[a+N/2][b+N/2];
	if( *ans > -1 ) return *ans;
	int i;
	rep(i,n) if( !rec( a+vx[i], b+vy[i] ) ) return *ans = 1;
	return *ans = 0;
}

int main()
{
	int i, j;
	rep(i,N) rep(j,N) mem[i][j] = -1;
	scanf( "%d%d%d%d", &x, &y, &n, &d );
	for( i = 0; i < n; i++ ) scanf( "%d%d", &vx[i], &vy[i] );
	printf( rec(x,y) ? "Anton\n" : "Dasha\n" );
	return 0;
}


#include <stdio.h>

int main(int argc, char **argv)
{
    double mid;
    int n, m, a;

    scanf("%d %d", &n, &m);

    mid = n / 2.0;
    a = m > mid ? m - 1: m + 1;

    if (n == 1) {
        printf("1\n");
    } else {
        printf("%d\n", a);
    }

	return 0;
}

#include<stdio.h>
main()
{
    int n,a,c;
    scanf("%d %d",&n,&a);
    if(n==1)
        printf("1\n");
    else if(a>n/2)
        printf("%d\n",a-1);
    else
        printf("%d\n",a+1);

    return 0;
}

#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if (n==1){printf("%d",n);}
	else{
	if ((float)n/2>m){printf("%d",m+1);}
	else if ((float)n/2<m){printf("%d",m-1);}
	else {printf("%d",m+1);}
	}
	return 0;
}

 #include<stdio.h>
int main(){
int n,m,a;
scanf("%d %d",&n,&m);

if(n==1)
printf("1");
else if((n-m)>(m-1))
printf("%d\n",m+1);
else
printf("%d\n",m-1);
return 0;
}

#include<stdio.h>
int main()
{
    long long int n,m,result;
    while(scanf("%lld%lld",&n,&m)==2)
    {  if(n==m&&m==1)
    result=1;
    else{  if((n-m-1)>=(m-1))
            result =m+1;
        else result =m-1;
    }
        printf("%lld\n",result);
    }
    return 0;
}

#include<stdio.h>
int main(void)
{
    int n,m,k;
    scanf("%d %d",&n,&m);
    if(n==1){
        printf("%d",n);
        return 0;
    }
    if(m>n/2){
        k=m-1;
    }
    else k=m+1;
    printf("%d",k);
    return 0;
}

#include <stdio.h>

int main() {
	int n, m;

	scanf("%d%d", &n, &m);
	printf("%d\n", n == 1 ? 1 : m - 1 >= n - m ? m - 1 : m + 1);
	return 0;
}

#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

 long long int test,n,c,o,d,e,r,i,fflag=0,m=0,flag=0,index,sum,max=0,min,l,x,j,z,b,k,count=0,gym=0,t1=0,t2=1,nextTerm,a;
  scanf("%lld %lld",&n,&a);
  if(n==a && n==1){
      printf("1");
  }else{

  printf("%lld",(n-a>a-1)?a+1:a-1);
  }

//printf("%d",a[n]);
    return 0;
}

#include <stdio.h>
int n, m;
int main(int argc, char **argv){
	scanf("%d%d", &n, &m);
	if (n == 1) printf("1\n");
	else if (m > n / 2) printf("%d\n", m - 1);
	else printf("%d\n", m + 1);
	return 0;
}

#include <stdio.h>

int main()
{
    int n, m, mid;
    scanf("%d %d", &n, &m);
    mid=n/2;

    if(n==1) printf("%d\n", 1);
    else if(m<=mid) printf("%d\n", m+1);
    else printf("%d\n", m-1);

    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,m,a,x,y;
    scanf("%lld %lld",&n,&m);
    if(n%2==0) {
         x=n/2;
         y=x+1;
        if(m==x)
            printf("%lld\n",y);
        else if(m==y)
        printf("%lld\n",x);
        else if (x<m)
            printf("%lld\n",m-1);
            else
                printf("%lld\n",m+1);

    }
    else
    {
        if(n==1)
            printf("1\n");
        else if ((n/2)<m)
            printf("%lld\n",m-1);
        else
            printf("%lld",m+1);

    }

}

#include<stdio.h>
int main(){
int n,m;
scanf("%d %d",&n,&m);
if(n==1){
printf("1\n");}
else if(m<=n/2){
printf("%d\n",m+1);
}
else
printf("%d\n",m-1);
return 0;
}

#include<stdio.h>
int m,n;
int main()
{
    scanf("%d %d",&n,&m);
    if (m==1&&n==1)
		printf("%d",1);
    else if (m<=n/2)
		printf("%d",m+1);
    else
		printf("%d",m-1);
}

#include <stdio.h>

int main() {
	int n, m;

	scanf("%d%d", &n, &m);
	printf("%d\n", n == 1 ? 1 : n - m > m - 1 ? m + 1 : m - 1);
	return 0;
}

#include<stdio.h>
int main()
{
long long int a,m,n,c;
scanf("%lld%lld",&n,&m);
if(n%2!=0)
{
if(m<(n+1)/2)
a=m+1;
else
a=m-1;
}
else
{
if(m>n/2)
a=m-1;
else //if(m<((n/2)+1))
a=m+1;
}
if(a<1)a++;
printf("%lld",a);
return 0;
}

#include <stdio.h>

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	int n, m, a;

	scanf("%d%d", &n, &m);
	if (n == 1)
		a = 1;
	else if (m - 1 >= n - m)
		a = m - 1;
	else
		a = m + 1;
	printf("%d\n", a);
	return 0;
}

#include <stdio.h>

int main()
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    if(n==1)
        printf("1\n");
    else
    {
    if((m-1)>=(n-m))
    {
        printf("%lld\n",m-1);
    }
    else
        printf("%lld\n",m+1);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int mid,ans;
	if(n%2==0)
	{
		mid = n/2;
		if(m>mid)
			ans= m-1;
		else
			ans = m+1;
	}
	else
	{
		mid = (n+1)/2;
		if(m>mid)
			ans=m-1;
		else if(mid==m)
			ans=m-1;
		else
			ans = m+1;
	}
		if(ans==0)
			ans=1;
	printf("%d\n",ans);

	return 0;

}

#include<stdio.h>
#include<stdlib.h>
int main()
{
long int m,n,a,b;
scanf("%li%li",&n,&m);
a=abs(m-1);
b=abs(n-m);
if(b>a)
printf("%li",m+1);
else if(a>b)
printf("%li",m-1);
else if(a==b && a!=0)
printf("%li",m-1);
else
printf("1");
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    long long int n,m,x1,x2;
    scanf("%lld%lld",&n,&m);
    if (n==1 &&m==1)
    {
        printf("1\n");
    }
    else if((n-m)>m-1)
    {
        printf("%lld\n",m+1);
    }
    else
    {
        printf("%lld\n",m-1);
    }
}

#include <stdio.h>
#include <math.h>

int main(){
    long long int n ,m;
    scanf("%I64d%I64d",&n,&m);
    if( n==1 ) { printf("1"); return 0;}
    if( ( m-1 ) >= ( n-m ) ) printf("%I64d",m-1);
    else printf("%I64d",m+1);

    return 0;
}

#include <stdio.h>
main() {
	int n,m,a;
	scanf("%d %d",&n,&m);
	if (m-1<n-m) a=m+1;
	else a=m-1;
	if (!a) a=m=1;
	if (a>n) a=m;
	printf("%d",a);
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int ans=0;
    if(n%2==1){
        if(m<=n/2) ans=m+1;
        else ans=m-1;
    }
    else{
        if(m<=n/2) ans=m+1;
        else ans=m-1;
    }
    if(n==1) ans=1;
    printf("%d\n",ans);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,c;
    scanf("%d %d",&n,&c);
    int a1=c-1;
    int a2=n-c;
    if(n==1)
    {
        printf("%d",n);
    }
    else if(a1>=a2)
    {
        printf("%d",a1);
    }
    else
    {
        printf("%d",c+1);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int a,n,m,b;
    while(~scanf("%d%d",&n,&m))
    {
        a=m-1;
        b=m+1;
        if(n==1)
            printf("1\n");
        else if(m-1<n-m) printf("%d\n",b);
        else printf("%d\n",a);
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,m,a;

    scanf("%lld %lld",&n,&m);

    if(n==1)
        a=n;
    else if((n-m)>(m-1))
        a=m+1;
    else
        a=m-1;

    printf("%lld\n",a);

    return 0;
}

#include <stdio.h>

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    if(n == 1)
        printf("1");
    else if(m - 1 < n - m)
        printf("%d", m + 1);
    else
        printf("%d", m - 1);

    return 0;
}

#include <stdio.h>
//#include <stdlib.h>

int main(void)
{
	long n, m, a, mid;
	scanf("%ld%ld", &n, &m);
	mid = (n + 1) / 2;
	if(m > mid)
	{
		a = m - 1;
	}
	else
	{
		if(m < mid)
		{
			a = m + 1;
		}
		else
		{
			if(n % 2)
			{
				a = m - 1;
			}
			else
			{
				a = m + 1;
			}
		}
	}
	if(a < 1)
	{
		a = 1;
	}
	else
	{
		if(a > n)
		{
			a = n;
		}
	}
	printf("%ld\n", a);
	return 0;
}

#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	if(m>1||n>1)
    {
	if(n==m)
	printf("%d",m-1);
	else if(m>n-m)
	printf("%d",m-1);
	else
	printf("%d",m+1);
	}
	else
	printf("%d",m);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define  max(a,b) a<b? 1:0
int main()
{
    int m,n,x;
    scanf("%d %d",&n,&m);
    x=max(m-1,n-m);
    if(n==1)
    {
            printf("%d",1);
            return 0;
    }
    if(x==0)
        printf("%d",m-1);
    else
        printf("%d",m+1);
}

#include<stdio.h>
#include<stdlib.h>
int main()
	{
	long long int n,m,a;scanf("%I64d%I64d",&n,&m);
	if(m>abs(n-m)) if(n==1) a=1;else a=m-1;
	else a=m+1;
	printf("%I64d",a);
	return 0;
	}

#include<stdio.h>
int main()
{
    int i,n,m,misha,res,x,choto,ans;
    scanf("%d %d",&n,&m);
    /*x=n-m;
    misha=(x/2)*(1+x);
    x=m-1;
    misha+=(x/2)*(1+x);
    x=n-1;
    choto=(x/2)*(1+x);
    ans=1;
    for(i=2;i<=n;i++)
    {
        if(i==m)
            continue;
        x=n-i;
        res=(x/2)*(1+x);
        x=i-1;
        res+=(x/2)*(1+x);
        if(choto>res)
        {
            choto=res;
            ans=i;
        }
    }*/
    if(n-m>m-1)
        ans=m+1;
    else if(n-m==m-1)
        ans=m-1;
    else
        ans=m-1;
    if(n==1)
        ans=1;
    printf("%d",ans);
}

#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int a;
    if(n==1)
    {printf("1\n");
    return 0;}
    if(n%2==0)
    {
        if(m>n/2)
        a=m-1;
        else if(m<n/2)
        a=m+1;
        else
        a=m+1;
    }
    else
    {
        if(m>(n+1)/2)
        a=m-1;
        else if(m<(n+1)/2)
        a=m+1;
        else
        a=m-1;
    }
    printf("%d\n",a);
    return 0;
}

#include<stdio.h>
int main()
{
	int n,m,mid,result;
	scanf("%d%d",&n,&m);
	if(n%2==0)
	{
		mid=n/2;
		if(m>mid)
		{
			result=m-1;
		}
		else
		{
			result=m+1;
		}
	}
	else
	{
		mid=n/2+1;
		if(m<mid)
			result=m+1;
		else
			result=m-1;
	}
	if(result==0)
		result=1;
	printf("%d",result);
	return 0;
}

#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==1)
        printf("1");
    else if(m-1>=n-m)
        printf("%d",m-1);
    else
        printf("%d",m+1);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main ()
{
    int n,m,c,a;
    scanf("%d %d",&n,&m);
    if(n==1 && m==1)
        a=1;
    else if(abs(n-m)>abs(m-1))
        a=m+1;
    else
        a=m-1;
    printf("%d\n",a);
}

#include <stdio.h>

int main()
{
	long int n, m;
	scanf("%ld %ld", &n, &m);
	if(n%2==0)
	{
		if(m > n/2)
		printf("%ld", m-1);
		else
		printf("%ld", m+1);
	}
	else
	{
		if(m==1, n==1)
		{
			printf("1");
		}
		else if(m >= (n+1)/2)
		printf("%ld", m-1);
		else
		printf("%ld", m+1);
	}
	return 0;
}

#include<stdio.h>
int main()
{
        int n,m;
        scanf("%d %d",&n,&m);
        if((float)m/n > 0.5)
                printf("%d",(m!=1 ? m-1 :1));
        else
                printf("%d",m+1);
        return 0;
}

#include <stdio.h>

int main()
{
    long long m,n,a,d;
    scanf("%I64d %I64d",&n,&m);
    if( n-m+1 > m  )
        a=m+1;
    else if( n == 1 )
        a=1;
    else
        a=m-1;
    printf("%I64d",a);
    return 0;
}

#include <stdio.h>

int main()
{
    int m,n;

    scanf("%d %d",&n,&m);

    if(n-m>m-1){
        printf("%d",m+1);
    }
    else if(n==1 && m==1){
        printf("1");
    }
    else if(n-m==m-1){
        printf("%d",m-1);
    }
    else{
        printf("%d",m-1);
    }
    return 0;
}

#include<stdio.h>
int main(){
int n,m,a;
scanf("%d %d",&n,&m);

if(n==1)
printf("1");
else if((n-m)>(m-1))
printf("%d\n",m+1);
else
printf("%d\n",m-1);
return 0;
}

#include<stdio.h>
int main()
{
    long long int a,b,m,n,z;
    scanf("%lld%lld",&n,&m);
    a=n-m;
    b=m-1;
    if(n==1&&m==1)
        printf("1\n");
    else if(b>=a)
        printf("%lld\n",m-1);
    else
        printf("%lld\n",m+1);
    return 0;
}

#include<stdio.h>
int main()
{
     int n,m,a,b;
     scanf("%d %d",&n,&m);
     if(n==1 && m==1)
     printf("1");
     else
     {
     a=m-1;
     b=n-m;
     if(a>=b)
     printf("%d",m-1);
     else
     printf("%d",m+1);
     }
     return 0;
}

#include<stdio.h>
int main()
{
int a,c,n,m;
scanf("%d%d",&n,&m);
c=1+rand()%(n-1);
if(n==1)
a=1;
else if((m-1)>=(n-m))
a=m-1;
else
a=m+1;
printf("%d",a);
}

#include<stdio.h>
int main() {
    long long int n,m;
    scanf("%lld%lld",&n,&m);
    if(n == m && n == 1)
        printf("1");
    else if(2*m <= n) {
        printf("%lld",m+1);
    }
    else {
        printf("%lld",m-1);
    }
    return 0;
}

#include<stdio.h>
int main(){
	long int m,n,left,right;
	scanf("%ld %ld",&n,&m);
	right = n-m;
	left = m-1;
	if(right>left){
		printf("%ld",m+1);
	}else if(left > right){
		printf("%ld",m-1);
	}else if(n==1){
		printf("1");
	}else{
		printf("%ld",m-1);
	}
	return 0;
}

#include <stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
  if(n==1)
  	printf("1\n");
  else if(m - 1 < n - m)
  	printf("%d",(m+1));
  else
  	printf("%d",(m-1));
	return 0;
}

#include<stdio.h>

int main()
{
    int a, b, c, n, m;
    scanf("%d %d", &n, &m);
    if(m==1 && n!=1){
        printf("%d", m+1);
        return 0;
    }
    if(n==1){
        printf("1");
        return 0;
    }
    if(m==n){
        printf("%d", n-1);
        return 0;
    }
    b = n-m;
    if(b<m){
        printf("%d", m-1);
    }
    else{
        printf("%d", m+1);
    }

    return 0;
}

#include<stdio.h>
int main()
{
   long long int a,b;
   scanf("%lld %lld",&a,&b);
   if (((a+1)/2)>b && (b+1)<=a)

   printf("%lld\n",b+1);
   else if (((a+1)/2)==b && (b+1)<=a && a%2==0)
   printf("%lld\n",b+1);

   else if (b-1>0)
   printf("%lld\n",b-1);
   else
   printf("%lld\n",b);
   return 0;
}

#include <stdio.h>

int main (void) {
    int n, a;
    int mid, and;

    scanf("%d %d", &n, &a);
    if(n==1) printf("1\n");
    else if(n%2==1){
        mid=(n/2)+1;
        if(a>mid) printf("%d\n", a-1);
        else if(a<mid) printf("%d\n",a+1);
        else printf("%d\n", mid-1);
    }
    else {
        mid=(n/2);
        if(a>mid) printf("%d\n", a-1);
        else printf("%d\n",a+1);
    }

    return 0;

}

#include<stdio.h>

int main()
{
	int n,m,a;
	scanf("%d %d",&n,&m);
	if(n-m>m-1)
		a=m+1;
	else
		a=m-1;
	if(a==0)
		a++;
	printf("%d",a);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long n, m;
    scanf("%ld %ld", &n, &m);
    if (n == 1) printf("1\n");
    else printf("%ld\n",(m > n/2)?m-1:m+1);
    return 0;
}

#include<stdio.h>
int main()
{
	int m,n,a;
	scanf ("%d%d",&n,&m);
	if (m>(n/2))
	{
		a=(m-1);
	}
	else
	{
		a=(m+1);
	}
	if (a==0)
	{
		a=a+1;
	}
	printf("%d",a);
	return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{

    long long n,m;
    scanf("%lld%lld",&n,&m);

    if(n==1)
       {  printf("%lld\n",m); return 0;}

    if(abs(n-m)>abs(1-m))
         printf("%lld\n",m+1);
    else
         printf("%lld\n",m-1);

    return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
	  int n,m;
	  scanf("%d %d",&n,&m);
	  if(n==1) printf("1\n");
	  else
	  {
		    int x=n-m, y=m-1;
		    if(x>y) printf("%d\n",m+1);
		    else printf("%d\n",m-1);
		    return 0;
	  }

}

#include <stdio.h>
int main()
{
    int n , m , a , d;
    scanf("%d%d" , &n , &m);
    if(n == 1)
    {
            printf("%d" , 1);
    }
    else
    {
        if(n - m > m - 1)
            a = m + 1;
        else
            a = m - 1;
        printf("%d" , a);
    }
    return 0;
}

#include<stdio.h>
int main()
{ unsigned long long n,m,r1,r2;
  scanf("%llu %llu",&n,&m);
  if(n==1&&m==1)
  printf("%llu",n);
  else{
  r1=m-1;
  r2=n-m;
  if(r1>=r2){
    printf("%llu",m-1);
  }
  else
  printf("%llu",m+1);
  }
  return 0;
}

#include <stdio.h>

int main()
{
    int n, m, a, c;
    scanf("%d %d", &n, &m);
    c=n-m;
    if(c>=m){
        a=m+1;
    }else{
        a=m-1;
    }
    if(n==1 && m==1) {
        a=1;
    }
    printf("%d\n", a);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,mid;
    scanf("%d%d",&n,&m);
    mid=n/2;
    if(m<=mid)
    {
        printf("%d",m+1);
    }
    else if(n==1)
        printf("1");
    else
        printf("%d",m-1);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main ()
{
    int n,m,c,a;
    scanf("%d %d",&n,&m);
    if(n==1 && m==1)
        a=1;
    else if(abs(n-m)>abs(m-1))
        a=m+1;
    else
        a=m-1;
    printf("%d\n",a);
}

#include <stdio.h>

int main(){

    int n,m,x;
    scanf("%d%d",&n,&m);
    if(n==1){
        printf("1\n");
        return 0;
    }
    if(n%2){
        x=n/2+1;
        if(m<x)
            printf("%d\n",m+1);
        else
            printf("%d\n",m-1);
    }
    else{
        x=n/2;
        if(m<=x)
            printf("%d\n",m+1);
        else
            printf("%d\n",m-1);
    }

    return 0;
}

#include <stdio.h>

int main()
{

	int n,m;
	scanf("%d %d",&n,&m);

	if(n==1 && m==1){
		printf("%d",m);
	}
	else if(m<=(n/2) || m==1){
		printf("%d",m+1);
	}
	else{
		printf("%d",m-1);
	}
	return 0;
}

#include <stdlib.h>
#include<stdio.h>
int main(void)
{
	long int n,m;
	scanf("%ld %ld",&n,&m);
	if(m == n && m!=1)
		printf("%ld", m-1);
	else if(m == n && m==1)
		printf("%ld", m);
	else if(m == 1)
		printf("2");
	else if(n-m > m-1)
		printf("%ld", m+1);
	else
		printf("%ld",m-1);

		return 0;
}

#include <stdio.h>
int main()
{
    long long n,m;
    scanf("%I64d %I64d",&n,&m);
    if(n==1)
        printf("1");
    else if(n%2==0){
        if(m>n/2)
            printf("%I64d",m-1);
        else
            printf("%I64d",m+1);
    }
    else{
        if(m>=n/2+1)
            printf("%I64d",m-1);
        else
            printf("%I64d",m+1);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int m, n, a;
	scanf("%d %d", &n, &m);
	if(n%2==1 && m==(n/2+1))
		a = m-1;
	else
	{
		if(m<=n/2)
			a=m+1;
		else
			a=m-1;
	}
	if(a<1)
		a++;

	printf("%d", a);
	return 0;
}

#include <stdio.h>

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {
	int n, m, a;

	scanf("%d%d", &n, &m);
	if (n == 1)
		a = 1;
	else if (m - 1 > n - m)
		a = m - 1;
	else if (n - m > m - 1)
		a = n - m;
	else
		a = min(m - 1, n - m);
	printf("%d\n", a);
	return 0;
}

#include <stdio.h>
int main()
{
    int n,m,a;
    while(scanf("%d %d",&n,&m)==2){
        if(n==1) printf("%d\n",n);
        else{
            if(n-m>m-1) a=m+1;
            else if(n-m<m-1) a=m-1;
            printf("%d\n",a);
        }
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{

    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(abs(n-m)>abs(1-m))
         printf("%lld\n",m+1);
    else
         printf("%lld\n",m-1);

    return 0;

}

#include <stdio.h>

int main()
{
    long long m,n,a,d;
    scanf("%I64d %I64d",&n,&m);
    if( n-m+1 > m  )
        a=m+1;
    else if( n == m )
        a=m;
    else
        a=m-1;
    printf("%I64d",a);
    return 0;
}

#include <stdio.h>

int main()
{
    long long int m,a,n;
    scanf("%I64d %I64d", &n,&m);
    {
        if((n-m)>m)
            printf("%I64d", m+1);
        else
            printf("%I64d", m-1);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int m,n;
	scanf("%d%d",&n,&m);
	if(abs(n-m)>abs(m-1))
	{
		printf("%d\n",m+1);
	}
	else if(abs(m-1)>abs(n-m))
	{
		printf("%d\n",m-1);
	}
	return 0;

}

#include<stdio.h>
main()
{
    int n,a,c;
    scanf("%d %d",&n,&a);
    if(n==1)
        printf("1\n");
    if(a>n/2)
        printf("%d\n",a-1);
    else
        printf("%d\n",a+1);

    return 0;
}

#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

 long long int test,n,c,o,d,e,r,i,fflag=0,m=0,flag=0,index,sum,max=0,min,l,x,j,z,b,k,count=0,gym=0,t1=0,t2=1,nextTerm,a;
  scanf("%lld %lld",&n,&a);
  if(n-a>a-1){
      printf("%lld",a+1);
  }else{
      if(n==a){
      printf("%lld",a);
      }else{
          printf("%lld",a-1);
      }
  }

//printf("%d",a[n]);
    return 0;
}

#include <stdio.h>

int main(void) {
	long n,m;
	scanf("%ld %ld", &n,&m);
	if(n-m>m-1)
	printf("%ld", m+1);
	else if(n-m<m-1)
	printf("%ld", m-1);
	else
	printf("%ld", m);
	return 0;
}

#include<stdio.h>
#include<stdbool.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    n=(n+1)/2;
    if(m>n)
        printf("%d\n",m-1);
    else
        printf("%d\n",m+1);
    return 0;
}

#include <stdio.h>

int main()
{
    long long m,n,a,d;
    scanf("%I64d %I64d",&n,&m);
    if( n-m+1 > m  )
        a=m+1;
    else
        a=m-1;
    printf("%I64d",a);
    return 0;
}

#include<stdio.h>
  int main ()
{
    int n=3,m=1;
    1<=m<n<=10^9;
     if (n-m>m-1){
        printf("%d",m+1);
    }
    else if (n-m<=m-1){
            printf("%d",m-1);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    long long int n,m,result;
    while(scanf("%lld%lld",&n,&m)==2)
    {
        if((n-m-1)>=(m-1))
            result =m+1;
        else result =m-1;
        printf("%lld\n",result);
    }
    return 0;
}

#include<stdio.h>
#include<stdbool.h>
int main()
{
    int n,m,d;
    scanf("%d%d",&n,&m);
    //printf("%d\n",n);
    if(n==1)
    {
        printf("1\n");
        return 0;
    }
    if(m-1>n-m)
        printf("%d\n",m-1);
    else
        printf("%d\n",m+1);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>
#define N 1000065
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1 && b==1){
		printf("2");
		return 0;
	}
	if(a-b>=b){
		printf("%d",b+1);
	}
	else printf("%d",b-1);
}

#include<stdio.h>
int main()
{
	float n,t;
	int a,m,temp;
	temp=n;
	scanf("%f %d",&n,&m);
	t=(n/2);
	if(m%2==0)
	{
		if(m<=t)
			a=m+1;
		else
			a=m-1;
	}
	else
	{
		if(m==((n/2)+1))
			a=m-1;
		else
		{
			if(m<=t)
				a=m+1;
			else
				a=m-1;
		}
	}
	printf("%d\n",a);
}

#include<stdio.h>
  int main ()
{
    int n,m;
    1<=m<n<=10^9;
    printf("n=? m=?");
    scanf("%d%d",&n,&m);
    if (n-m>m-1){
        printf("%d",m+1);
    }
    else if (n-m<=m-1){
            printf("%d",m-1);
    }
    return 0;
}

#include <stdio.h>

int main()
{
    int m, n, a;
    scanf("%d%d", &n, &m);
    if(n-m >= m){
        printf("%d", m+1);
    }
    else{
        printf("%d", m-1);
    }

    return 0;
}

#include<stdio.h>
int main ()
{
    int n,a,m;
    scanf("%d %d",&n,&m);
    a=n-1;
    if(n-1==m)
        a=m-1;
    printf("%d\n",a);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  int n,m,a;
  scanf("%d",&n);
  scanf("%d",&m);

  if(m==1){a=m+1;}
  else{
      if(m==n){a=m-1;}
      else{
         if(n-m>=m-1){a=m+1;}
         else{a=m-1;}
       }
    }

   printf("%d",a);

  return 0;

}

#include <stdio.h>

int main(void)
{
    long m,n;
    scanf("%ld%ld",&n,&m);
    //if(n==1 && m==1)
    //printf("1\n");
    if( n-m > m-1)
        printf("%ld\n",m+1);
    else if(m-1 > n-m)
        printf("%ld\n",m-1);
    else
        printf("%ld\n",m-1);
    // your code goes here
    return 0;
}

#include<stdio.h>
int main()
{
	long long int n,m,temp1,temp2;
	scanf("%lld%lld",&n,&m);
	temp1= n-m;
	temp2= m-1;
	if(n==1 && m==1)
	{
		printf("1\n");
	}
	else
	{
		if(temp1>=temp2)
		{
			printf("%lld\n",m+1);
		}
		else
		{
			printf("%lld\n",m-1);
		}
	}
	return 0;
}

#include <stdio.h>

int main()
{
    int n, m, a, c;
    scanf("%d %d", &n, &m);
    c=n-m;
    if(c>m){
        a=m+1;
    }else{
        a=m-1;
    }
    if(n==1 && m==1) {
        a=1;
    }
    printf("%d\n", a);

    return 0;
}

#include <stdio.h>

int n, m;

int main() {
	int left, right, ans;

	scanf("%d %d", &n, &m);
	left = m - 1;
	right = n - m;
	ans = (left >= right) ? m - 1 : m + 1;
	printf("%d\n", ans);
	return 0;
}

#include<stdio.h>

int main()
{
  long int n,m;
    scanf("%ld%ld",&n,&m);
    if(n==1)
        printf("1");
    if(n/2>=m)
    {
        printf("%ld",m+1);
    }
    else
        printf("%ld",m-1);
    return 0;

}

#include <stdio.h>

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	if(n%2==0)
	{
		if(m > n/2)
		printf("%d", m-1);
		else
		printf("%d", m+1);
	}
	else
	{
		if(m==1, n==1){
			printf("1");
		}
		else if(m > (n+1)/2)
		printf("%d", m-1);
		else
		printf("%d", m+1);
	}
	return 0;
}

#include<stdio.h>
int main()
{
	float n,t;
	int a,m,temp;
	temp=n;
	scanf("%f %d",&n,&m);
	t=(n/2);
	if(n==1)
		a=1;
	else
	{
	if(m%2==0)
	{
		if(m<=t)
			a=m+1;
		else
			a=m-1;
	}
	else
	{
		if(m==((n/2)+1))
			a=m+1;
		else
		{
			if(m<=t)
				a=m+1;
			else
				a=m-1;
		}
	}
	}
	printf("%d\n",a);
}

#include <stdio.h>
#include <stdlib.h>

int main(){
	int m,n;
	scanf("%d %d",&n,&m);
	if(n>((2*m)-1)) printf("%d\n",(m+1));
	else if(n<((2*m)-1)) printf("%d\n",m-1);
	else printf("%d\n",m);
	return 0;
}

#include<stdio.h>
int main()
{
int a,c,n,m;
scanf("%d%d",&n,&m);
c=1+rand()%(n-1);
if((m-1)>=(n-m))
a=m-1;
else if(n==1)
a=1;
else
a=m+1;
printf("%d",a);
}

#include<stdio.h>
int main ()
{
    int n,m,i,count=0,old_count=0,j,rem;
    scanf("%d %d",&n,&m);
    int ara[n+1];
    for(i=m+1; i<=n; i++)
    {
        if(abs(n-i)<abs(n-m))
        {
            ara[count]=i;
            count++;
        }
    }
    count--;
    if(n==m || n-m==1)
        rem=m-1;
    for(i=m+1; i<=n; i++)
    {
        for(j=1; j<=count; j++)
        {
            if(abs(ara[j]-i)<abs(ara[j]-m))
                count++;
        }
        if(count>old_count)
        {
            rem=i;
            old_count=count;
        }
        count=0;
    }
    printf("%d\n",rem);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{

    int a,b,c,n,m;
    scanf("%d%d",&n,&m);
    if((m-1)<(n-m))
    {
        a=m+1;
    }
    if(m-1>n-m)
    {
        a=m-1;
    }

    printf("%d",a);

}

#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if ((float)n/2>m){printf("%d",m+1);}
	else if ((float)n/2<m){printf("%d",m-1);}
	else {printf("%d",m+1);}
}

#include <stdio.h>
int main()
{
    int m,n,a;
    scanf("%d %d",&n,&m);
    if(n-m>m-1)    {
        a=m+1;
    }
    else    {
        a=m-1;
    }
    printf("%d\n",a);
    return 0;
}

#include<stdio.h>
int main()
{
	int n=0,m=0;
	scanf("%d %d",&n,&m);
    if(n-m>=m-1)
	printf("%d",m+1);
	else
	printf("%d",m-1);
	return 0;

}

#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if ((float)n/2>m){printf("%d",m+1);}
	else {printf("%d",m-1);}
}

#include <stdio.h>

int main()
{
    long long m,n,a,d;
    scanf("%I64d %I64d",&n,&m);
    if( n-m+1 > m  )
        a=m+1;
    else
        a=m-1;
    printf("%I64d",a);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
main()
{
	long int n,m,i,j;
	scanf("%ld %ld",&n,&m);
	i=m-1;
	j=n-m;
	if(i==j || i>j || m==n)
	{
		printf("%ld",m-1);
	}
	else if(j>i || m==1)
	{
		printf("%ld",m+1);
	}

}

#include<stdio.h>
int main()
{
    int n,a,x,m;
    scanf("%d %d",&n,&m);
    x=2*m-1;
    if(n<=x){
        a=m-1;
        printf("%d",a);
    }else{
        a=m+1;
        printf("%d",a);
    }
    return 0;
}

#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

 long long int test,n,c,o,d,e,r,i,fflag=0,m=0,flag=0,index,sum,max=0,min,l,x,j,z,b,k,count=0,gym=0,t1=0,t2=1,nextTerm,a;
  scanf("%lld %lld",&n,&a);
  if(n-a>a-1){
      printf("%lld",a+1);
  }else{
      if(n-1==a-1){
      printf("%lld",a);
      }else{
          printf("%lld",a-1);
      }
  }

//printf("%d",a[n]);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n%2==0)
    {
        if(m<n/2)
        {
            printf("%d\n",m+1);
        }
        else if(m>n/2)
        {
            printf("%d\n",m-1);
        }
        else
        {
            printf("%d\n",m);
        }
    }
    else
    {
        if(m<(n+1)/2)
        {
            printf("%d\n",m+1);
        }
        else if(m>(n+1)/2)
        {
            printf("%d\n",m-1);
        }
        else
        {
            printf("%d\n",m);
        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define  max(a,b) a<b? 1:0
int main()
{
   	int m,n,x;
   	scanf("%d %d",&n,&m);
   	x=max(m-1,n-m);
   	if(x==0)
   		printf("%d",m-1);
   	else
   		printf("%d",m+1);
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>
#define N 1000065
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a-(b+1)>=b-2){
		printf("%d",b+1);
	}
	else printf("%d",b-1);
}

#include <stdio.h>

int main()
{
	int n,m,z,x,y;
	scanf("%d %d" ,&n,&m);
	z=n/2;
	if (n!=1)
		{
		if (m<=z)
		{y=m+1;
		printf("%d" ,y);
		}
		else
		{x=m-1;
		printf("%d" ,x);
		}
		}
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{

    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(abs(n-m)>abs(1-m))
         printf("%lld\n",m+1);
    else
         printf("%lld\n",m-1);

    return 0;

}

# include <stdio.h>
# include <stdlib.h>
# define min(a,b) (a < b ? a : b)

int main () {
	int n, m, resposta;
	scanf("%d%d", &n, &m);
	if (n - m > m - 1)
		resposta = ((n - m) >> 1) + m;
	else
		resposta = (m >> 1) + 1;
	printf("%d\n", resposta);
	return(0);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int m, n, a;
	scanf("%d %d", &n, &m);
	if(n%2==1 && m==(n/2+1))
		a = m-1;
	else
	{
		if(m<=n/2)
			a=m+1;
		else
			a=m-1;
	}
	printf("%d", a);
	return 0;
}

#include<stdio.h>
#include<math.h>
long long int n,m,x;
int main()
{
   long long int a;
    scanf("%lld %lld",&n,&m);
    x=n/2;
    if((abs(n-m))>x)
       {
           a=m+1;
       }
    else if((abs(n-m))<x)
        {
            a=m-1;
        }
    printf("%lld\n",a);
    return 0;

}

#include<stdio.h>
#include<math.h>
int main()
{
	long long int n,m;
	scanf("%I64d %I64d",&n,&m);
	/*int odd=0,even=0;
	if(n%2==0)
		even=1;
	else
		odd=1;
	/*if(!odd && even)
	{
		if(n-m>)
	}*/
	if(n-m>m-1)
		printf("%I64d",m+1);
	else if(n-m<=m-1)
		printf("%I64d",m-1);
	return(0);

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,m,a;

    scanf("%lld %lld",&n,&m);

    if((n-m)==(m-1))
        a=m;
    else if((n-m)>(m-1))
        a=m+1;
    else
        a=m-1;

    printf("%lld\n",a);

    return 0;
}

#include<stdio.h>
int main()
{
    int i,n,m,misha,res,x,choto,ans;
    scanf("%d %d",&n,&m);
    /*x=n-m;
    misha=(x/2)*(1+x);
    x=m-1;
    misha+=(x/2)*(1+x);
    x=n-1;
    choto=(x/2)*(1+x);
    ans=1;
    for(i=2;i<=n;i++)
    {
        if(i==m)
            continue;
        x=n-i;
        res=(x/2)*(1+x);
        x=i-1;
        res+=(x/2)*(1+x);
        if(choto>res)
        {
            choto=res;
            ans=i;
        }
    }*/
    if(n-m>m-1)
        ans=m+1;
    else if(n-m==m-1)
        ans=m+1;
    else
        ans=m-1;
    if(n==1)
        ans=1;
    printf("%d",ans);
}

#include <stdio.h>

int main()
{
    long long int n,m;
    scanf("%lld %lld",&n,&m);
    if(m!=1)
    {
        printf("%lld\n",m-1);
    }
    else
        printf("%lld\n",m+1);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  if(m==n)
  printf("%d",m);
  else
  if(m<=n/2)
  printf("%d",m+1);
  else
  printf("%d",m-1);
}

#include <stdio.h>

int main()
{
	int n,m,z,x,y;
	scanf("%d %d" ,&n,&m);
	z=n/2;
	if (m<=z)
		{y=m+1;
		printf("%d" ,y);
		}
	else
		{x=m-1;
		printf("%d" ,x);
		}
}

#include <stdio.h>
int main ()
{
    int n,m,x;
    scanf("%d %d",&n,&m);
    if(n%2==0) {
        x=n/2;
    }
    else{
        x=n/2+1;
    }
    if(x==m) {
        x--;
    }
    printf("%d\n",x);
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {int a,b;
  scanf("%d%d",&a,&b);
   if(b>a/2){
       printf("%d",b-1);
   }else{printf("%d",b+1);}
    return 0;
}

#include <stdio.h>

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	if ((n-m)>(m-1)) printf("%d\n", m+1);
	else printf("%d\n", m-1);
	return 0;
}

#include <stdio.h>
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a,p;
    if(n%2==0)
    {
        p=n/2+1;
    }
    else
    {
        p=n/2+1;
    }
    if(m>=p)
    {
        a=m-1;
    }
    else
    {
        a=m+1;
    }
    printf("%d",a);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){
	int m,n;
	scanf("%d %d",&n,&m);
	if(n>((2*m)-1)) printf("%d\n",(m+1));
	else if(n<((2*m)-1)) printf("%d\n",m-1);
	else printf("%d\n",m);
	return 0;
}

#include <stdio.h>

int main(void) {
	long n,m;
	scanf("%ld %ld", &n,&m);
	if(n-m>m)
	printf("%ld", m+1);
	else
	printf("%ld", m-1);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main (int argc, char * argv[]) {
    int n, m, a;
    scanf ("%d %d", &n, &m);

    int middle = n / 2 + n % 2;
    if (m < middle) {
        a = m + 1;
    } else if (m > middle) {
        a = m - 1;
    } else {
        a = m + ((m == 1 || m == n) ? 0 : (n % 2 == 0 ? 1 : -1));
    }

    printf ("%d\n", a);

    return 0;
}

#include<stdio.h>
int main() {
    long long int n,m,k;
    scanf("%lld %lld",&n,&m);
    k=n-m;
    if(m==1)
        printf("%lld\n",m+1);
    else if(m==n)
        printf("%lld\n",m-1);
    else{
        if(k>m-1)
             printf("%lld\n",m+1);
        else
             printf("%lld\n",m-1);
    }
return 0;
}

#include <stdio.h>
int main ()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==1)printf("%d\n",n);
    else
    {
    if(m<=n/2)printf("%d\n",m+1);
    if(m>=n/2)printf("%d\n",m-1);
    }
    return 0;
}

#include<stdio.h>
int main()
{
	long int m,n,i;
	scanf("%ld %ld",&n,&m);
	if(m==1 && n==1)
		i=1;
	else if(m<=(1+n)/2 && n%2!=0)
	i=m+1;
	else
		i=m-1;
	printf("%ld\n",i);
}

#include<stdio.h>
int main ()
{
    int n,a,m;
    scanf("%d %d",&n,&m);
    a=m+1;
    if(n-m==1 || n==m)
        a=m-1;
    printf("%d\n",a);
    return 0;
}

#include <stdio.h>
int main()
{
    long long int n,m,_mid;
    scanf("%I64d %I64d",&n,&m);
    _mid = n/2;
//    (_mid>m)? m+=1 : m-=1;
    if(_mid >=m) m+=1;
    else m-=1;
    if(m==0) m=2;

    printf("%I64d",m);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	int n, m;

	scanf("%d %d", &n, &m);
	if(n == 1) printf("0\n");
	else if(n - m > m - 1) printf("%d\n", m+1);
	else printf("%d\n", m-1);

	return 0;
}

//misha的初始数字是m
//andrew的初始数字是a
//在1到n之间选择！
//c是一个随机数
//看谁的数接近c，距离相同misha赢！
//距离不同谁近，谁赢！
//n是可以选择的数字范围！
//这是一个概率问题！
//每一个都计算一遍时间肯定超时
//因为题目设置为10^9级别的问题！
//只能先实现一个看有没有超时！
//我的想法是a必须选择中间位置，才能获取最大概率！
/*interface*/
/*interface implementation*/
/*client*/
#include<stdio.h>
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int a;
	for(a=1;a<=n;a++) {

	}
	return 0;
}

#include <stdio.h>
int main()
{
    int m,n,a;
    scanf("%d %d",&n,&m);
    if(n-m>m-1)    {
        a=m+1;
    }
    else    {
        a=m-1;
    }
    printf("%d\n",a);
    return 0;
}

#include <stdio.h>

int main()
{
    long long int m,a,n;
    scanf("%I64d %I64d", &n,&m);
    {
        if((n-m)>(m-1))
            printf("%I64d", m+1);
        else if((n-m)<(m-1))
            printf("%I64d", m-1);
        else
            printf("%I64d", m-1);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>

int main(){
    long long int n ,m;
    scanf("%I64d%I64d",&n,&m);
    if( m==1 ) { printf("1"); return 0;}
    if( ( m-1 ) >= ( n-m ) ) printf("%I64d",m-1);
    else printf("%I64d",m+1);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,a,b;
    scanf("%d %d",&n,&m);
    if(m<=(n/2))
    {
        printf("%d",m+1);
    }
    else
        printf("%d",m-1);
    return 0;
}

int main()
{
    int n,m,a;
    scanf("%d%d",&n,&m);
     if(abs(m-1)>abs(n-m)){a=m-1;}
     else if(abs(m-1)<abs(n-m)) a=m+1;
     else
     {
         if(m!=n)a=n;
         else a=1;
     }
     printf("%d\n",a);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,m,a;

    scanf("%lld %lld",&n,&m);

    if(n==m)
    {
        printf("%lld\n",n);
        return 0;
    }
    if((n-m)>(m-1))
    {
        a=m+1;
    }
    else
        a=m-1;

    printf("%lld\n",a);

    return 0;
}

#include <stdio.h>

int main(void)
{
    long m,n;
    scanf("%ld%ld",&n,&m);
    if(n==1 && m==1)
        printf("1\n");
    if( n-m > m-1)
        printf("%ld\n",m+1);
    else if(m-1 > n-m)
        printf("%ld\n",m-1);
    else
        printf("%ld\n",m-1);
    // your code goes here
    return 0;
}

#include<stdio.h>
  int main ()
{
    int n,m;
    1<=m<n<=10^9;
    scanf("%d%d",&n,&m);
    if(n=1){
        printf("%d",n);
    }
     else if (n-m>m-1){
        printf("%d",m+1);
    }
    else if (n-m<=m-1){
            printf("%d",m-1);
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#define  max(a,b) a<b? 1:0
int main()
{
   	int m,n,x;
   	scanf("%d %d",&n,&m);
   	x=max(m-1,n-m);
   	if(n==1)
   	{
	   		printf("%d",0);
	   		return 0;
   	}
   	if(x==0)
   		printf("%d",m-1);
   	else
   		printf("%d",m+1);
}

#include<stdio.h>
int main()
{
	int n,m,a,t;
	scanf("%d %d",&n,&m);
	t=n/2;

	if(n==1)
		a=1;
	else
	{
		if(m<t)
			a=m+1;
		else
			a=m+1;
	}
	printf("%d",a);
}

#include<stdio.h>
#include<stdlib.h>

int main(void)
{

    long long n,m;
    scanf("%lld%lld",&n,&m);
    if(abs(n-m)>abs(1-m))
         printf("%lld\n",m+1);
    else
         printf("%lld\n",m-1);

    return 0;

}

#include<stdio.h>
#include<stdlib.h>

int main(){
    int n,m;
    scanf("%d%d",&n,&m);

    float L=(float)(m-1)/(float)n;
    float R=(float)(n-m)/(float)n;

    if(n==m)
        printf("%d",n);
        return 0;

    if(L>R)
        printf("%d",m-1);

    else if(R>L)
        printf("%d",m+1);

    else if(L==R)
        printf("%d",m-1);

    return 0;
}

#include<stdio.h>
#include<stdbool.h>
int main()
{
    int n,m,d;
    scanf("%d%d",&d,&m);
    n=(d+1)/2;
    //printf("%d\n",n);
    if(n==1)
    {
        printf("1\n");
        return 0;
    }
    if(n==m)
    {
        if(d&1)
            printf("%d\n",m-1);
        else
            printf("%d\n",m+1);
        return 0;
    }
    if(m>n)
        printf("%d\n",m-1);
    else
        printf("%d\n",m+1);
    return 0;
}

#include <stdio.h>
#include<string.h>
#include<math.h>

int main(void){

 long long int test,n,c,o,d,e,r,i,fflag=0,m=0,flag=0,index,sum,max=0,min,l,x,j,z,b,k,count=0,gym=0,t1=0,t2=1,nextTerm,a;
  scanf("%lld %lld",&n,&a);
  if(n-a>a-1){
      printf("%lld",a+1);
  }else{
    if(n-a<a-1){
        printf("%lld",a-1);
    }else{
        printf("%lld",a-1);
    }
  }

//printf("%d",a[n]);
    return 0;
}

#include<stdio.h>
int main()
{
	float n,t,m;
	int a,temp,temp2;
	temp=n;
	temp2=m;
	scanf("%f %f",&n,&m);
	t=(n/2);
	if(n==1)
		a=1;
	else
	{
	if(temp%2==0)
	{
		if(m<=t)
			a=m+1;
		else
			a=m-1;
	}
	else
	{
		if(m==((n/2)+1))
			a=temp2-1;
		else
		{
			if(m<=t)
				a=temp2+1;
			else
				a=temp2-1;
		}
	}
	}
	printf("%d\n",a);
}

#include<stdio.h>

int main()
{
  long int n,m;
    scanf("%ld%ld",&n,&m);
    if(m>=n/2)
    {
        printf("%ld",m-1);
    }
    else
        printf("%ld",m+1);
    return 0;

}

#include <stdio.h>

int main (void) {
    int n, a;
    int mid, and;

    scanf("%d %d", &n, &a);
    if(n%2){
        mid=(n/2)+1;
        if(a>mid) printf("%d\n", mid);
        else if(a<mid) printf("%d\n",a+1);
        else printf("%d\n", mid);
    }
    else {
        mid=(n/2);
        if(a>mid) printf("%d\n", mid);
        else if(a<mid) printf("%d\n",a+1);
        else printf("%d\n", mid+1);
    }

    return 0;

}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {int a,b;
  scanf("%d%d",&a,&b);
   if(b>a/2){
       printf("%d",b-1);
   }else{printf("%d",b+1);}
    return 0;
}

#include<stdio.h>
  int main ()
{
    int n,m;
    1<=m<n<=10^9;
    scanf("%d%d",&n,&m);
     if (n-m>m-1){
        printf("%d",m+1);
    }
    else if (n-m<=m-1){
            printf("%d",m-1);
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int main(){

  int n,m,a;
  scanf("%d",&n);
  scanf("%d",&m);

  if(m==1){a=m+1;}
  else{
      if(m==n){a=m-1;}
      else{
         if(n-m>=m-1){a=m+1;}
         else{a=m-1;}
       }
    }

   printf("%d",a);

  return 0;

}