#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <numeric>
#include <cassert>
#include <random>
#include <stdarg.h>
#include <string.h>
#include <stack>
#include <string>
#include <map>
#include <stdio.h>
#include <fstream>
#include <limits.h>
#include <set>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <functional>

#define int long long int

#define DEBUG
#define NULL 0

#include <iostream>
#include <vector>
using namespace std;

vector<int> indexOf(char* str, char* pattern)
{
	vector<int> v;
	int slen = strlen(str);
	int patlen = strlen(pattern);
	for(int i = 0; i<slen; i++) {
		bool match = true;
		for(int j = 0; j<patlen; j++) {
			if(str[i+j] != pattern[j]) {
				match = false;
			}
		}
		if(match) {
			v.push_back(i);
		}
	}
	return v;
}

int maxBorder(char* a)
{
	int len = strlen(a);

	char* pref = new char[len];
	char* suff = new char[len];

	int max = 0;

	for(int i = 0; i<len; i++) {
		copy(a, a+i, pref);
		pref[i] = '\0';

		copy(a+len-i, a+len, suff);
		suff[i] = '\0';

		if(!strcmp(pref, suff)) {
			max = strlen(pref);
		}
	}

	delete[] pref;
	delete[] suff;
	return max;
}

int* getBordersArray(char* str)
{
	int len = strlen(str);
	int* res = new int[len]();
	char* buf = new char[len];
	for(int i = 0; i<len; i++) {
		copy(str, str+i+1, buf);
		buf[i+1] = '\0';
		int max = maxBorder(buf);
		res[i] = max;
	}
	return res;
}

int* getBordersArrayDP(char* str)
{
	int len = strlen(str);
	int* dp = new int[len]();
	for(int i = 1; i<len; i++) {
		int index = dp[i-1];
		while(1) {
			if(str[index] == str[i]) {
				dp[i] = index + 1;
				break;
			}
			if(index > 0) {
				index = dp[index - 1];
			} else {
				break;
			}
		}
	}
	return dp;
}

ostream_iterator<int> oi(cout, " ");

class Pair;

class Item
{
	friend ostream &operator<< ( ostream & out, const Pair & c );
	friend istream &operator>> ( istream & out, Pair & c );

public:
	Item(string des) {
		description = des;
	}

	int keyF() {
		key = description.length();
		return key;
	}

	string toString() {
		return description;
	}

	int key;

	string description;
};

ostream & operator<<( ostream & out, const Item & c  )
{
	out << c.description;
	return out;
}

istream & operator>>( istream & in, Item & c  )
{
	in>>c.description;
	return in;
}

ostream & operator<<( ostream & out, pair<int, int>& c  )
{
	out << "<" <<c.first << ", ";
	out << c.second << ">" << endl;
	return out;
}

istream & operator>>( istream & in, pair<int, int>& c  )
{
	in>>c.first;
	in>>c.second;
	return in;
}

void print()
{
	std::cout << endl;
}

template<typename A>
void print(A value)
{
	std::cout << value;
}

template<typename A, typename B>
void print(A value1, B value2)
{
	cout << value1 << " " << value2;
}

template<typename A, typename B, typename C>
void print(A value1, B value2, C value3)
{
	cout << value1 << " " << value2 << " " << value3;
}

template<typename A, typename B, typename C, typename D>
void print(A value1, B value2, C value3, D value4)
{
	cout << value1 << " " << value2 << " " << value3 << " " << value4;
}

template<typename E>
E read()
{
	E value;
	cin >> value;
	return value;
}

string readString()
{
	char* s = new char[1000];
	fgets(s, 1000, stdin);
	return string(s);
}

template<typename A>
void println(A value)
{
	std::cout << value << endl;
}

template<typename A, typename B>
void println(A value1, B value2)
{
	cout << value1 << " " << value2 << endl;
}

template<typename A, typename B, typename C>
void println(A value1, B value2, C value3)
{
	cout << value1 << " " << value2 << " " << value3 << endl;
}

template<typename A, typename B, typename C, typename D>
void println(A value1, B value2, C value3, D value4)
{
	cout << value1 << " " << value2 << " " << value3 << " " << value4 << endl;
}

int randomint(int min, int max)
{
	if(max == min) {
		return max;
	}
	return rand()%(max-min+1)+min;
}

class Pair
{
	friend ostream &operator<< ( ostream & out, const Pair & c );
	friend istream &operator>> ( istream & out, Pair & c );

public:
	Pair(Item* p);
	int key;
	Item* value;
};

Pair::Pair(Item* b)
{
	key = b->key;
	value = b;
}

ostream & operator<<( ostream & out, const Pair& c  )
{
	out<< "(" << c.value->key << " -> " << (c.value->toString()) << ")";
	return out;
}

template<typename E>
class Array
{
public:
	int size;
	Array<E>(int _capacity) {
		capacity = _capacity;
		array = new E[capacity];
		size = capacity;
		for(int i =0; i<size; i++) {
			array[i] = NULL;
		}
	}

	void sort() {
		std::sort(&array[0], &array[size]);
	}

	Array() {
		capacity = 1024;
		array = new E[capacity];
		size = 0;
	}

	Array(vector<E>& vect) {
		int _size = vect.size();
		capacity = _size*2;
		size = _size;
		array = new E[capacity];
		for(int i =0; i<size; i++) {
			array[i] = vect[i];
		}
	}

	Array(int minBound, int maxBound, int _size) {
		srand(_size);
		capacity = _size*2;
		size = _size;
		array = new E[capacity];
		for(int i = 0; i<size; i++) {
			array[i] = randomint(minBound, maxBound);
		}
	}

	void add(E item);
	int leftBinarySearch(E& item);
	int rightBinarySearch(E& item);
	pair<int, int> equalRange(E& item);
	bool binarySearch(E& item);
	E* begin();
	E* end();
	vector<E> toVector();
	void toString();
	E& operator[](int i);
	E& index(int i);
	E* array;
	void null(void) {
		for(int i =0; i<size; i++) {
			array[i] = NULL;
		}
	}
private:
	int capacity;
	void ensureCapacity(int cap);
};

template <typename E>
void Array<E>::ensureCapacity(int cap)
{
	capacity = capacity*2;
	E* newArray = new E[capacity];
	memcpy(newArray, array, sizeof(E)*size);
	delete[] array;
	array = newArray;
}

template <typename E>
void Array<E>::toString()
{
	int i = 0;
	E* begin = array;
	cout << "[";
	while(i<size) {
		if(i == size-1) {
			cout << *array;
		} else {
			cout << *array << " ";
		}
		array++;
		i++;
	}
	cout << "]";
	cout << endl;
	array = begin;
}

template <typename E>
void Array<E>::add(E item)
{
	if(capacity<size+1) {
		ensureCapacity(size+1);
	}
	array[size] = item;
	size++;
}

template <typename E>
E* Array<E>::begin()
{
	return array;
}

template <typename E>
E* Array<E>::end()
{
	return array + size;
}

template <typename E>
int Array<E>::leftBinarySearch(E& item)
{
	return lower_bound(array, array+size, item)-array;
}

template <typename E>
int Array<E>::rightBinarySearch(E& item)
{
	return upper_bound(array, array+size, item)-array;
}

template <typename E>
pair<int, int> Array<E>::equalRange(E& item)
{
	pair<int*, int*> p(0, 0);
	p = equal_range(array, array + size, item);
	return make_pair(p.first - array, p.second - array);
}

template <typename E>
bool Array<E>::binarySearch(E& item)
{
	return binary_search(array, array + size, item);
}

template <typename E>
vector<E> Array<E>::toVector()
{
	vector<E> res = vector<E>(size);
	for(int i =0; i<res.size(); i++) {
		res[i] = array[i];
	}
	return res;
}

template<typename T>
ostream & operator<<( ostream & out, Array<T>& c  )
{
	for(int i = 0; i<c.size; i++) {
		out << c[i] << " ";
	}
	return out;
}

ostream & operator<<( ostream & out, Array< pair<int, int> >& c  )
{
	for(int i = 0; i<c.size; i++) {
		out << c[i];
	}
	return out;
}

template<typename T>
istream & operator>>( istream & in, Array<T>& c  )
{
	for(int i = 0; i<c.size; i++) {
		in >> c[i];
	}
	return in;
}

ostream & operator<<( ostream & out, map<int, int>& c  )
{
	map<int, int>::iterator it = c.begin();
	while(it!=c.end()) {
		pair<int, int> entry = *it;
		out << entry;
		it++;
	}
	return out;
}

template <typename E>
E& Array<E>::operator[] (int i)
{
#ifdef DEBUG
	if(i<size && i>=0) {
		return array[i];
	} else {
		cout << "Array index out of bounds, index is " << i << ", size is " << size << endl;
		cout << "Array is " << endl;
		toString();
		assert(0);
	}
#endif

#ifndef DEBUG
	return array[i]
#endif
}

       template<typename E>
class Matrix
{
public:
	int rows;
	int columns;
	Array<E> array;

	E& get(int x, int y);
	void set(int x, int y, E& value);
	E& operator()(int x, int y);
	Matrix<E> transpose();

	pair<E*, E*> getRow(int y);

	Matrix<E>(int c, int r) {
		rows = r;
		columns = c;
		array = Array<E>(rows*columns);
		array.null();
	}

	void swap(Matrix<E>& other) {
		std::swap(array, other.array);
		std::swap(rows, other.rows);
		std::swap(columns, other.columns);
	}

	Matrix<E>(int _columns, int _rows, int minBound, int maxBound) {
		rows = _rows;
		columns = _columns;
		int size = _rows*_columns;
		array = Array<E>(minBound, maxBound, size);
	}

private:
};

template<typename E>
Matrix<E> Matrix<E>::transpose()
{
	Matrix<int> b(rows, columns);
	for(int x = 0; x<columns; x++) {
		for(int y = 0; y<rows; y++) {
			b(y, x) = array.array[x+y*columns];
		}
	}
	return b;
}

template <typename E>
E& Matrix<E>::operator()(int x, int y)
{
#ifdef DEBUG
	if(x>=columns || x<0) {
		cout << "x must be in range [0; " << columns - 1 << "], but it is " << x << endl;
		assert(0);
	}
	if(y>=rows || y<0) {
		cout << "y must be in range [0; " << rows - 1 << "], but it is " << y << endl;
		assert(0);
	}
	return array.array[x+y*columns];
#endif
#ifndef DEBUG
	return array.array[x+y*columns];
#endif
}

template<typename T>
istream & operator>>( istream & in, Matrix<T>& c  )
{
	for(int y = 0; y<c.rows; y++) {
		for(int x = 0; x<c.columns; x++) {
			in >> c(x, y);
		}
	}
	return in;
}

template<typename E>
pair<E*, E*> Matrix<E>::getRow(int y)
{
	E* f = array.array + y*columns;
	E* s = array.array + (y+1)*columns;
	pair<E*, E*> p(f, s);
	return p;
}

template<typename T>
ostream & operator<<( ostream & out, Matrix<T>& c  )
{
	for(size_t y = 0; y<c.rows; y++) {
		for(size_t x = 0; x<c.columns; x++) {
			out << c(x, y) << " ";
		}
		out << endl;
	}
}

int bpow(int a, int b)
{
	if(b == 0) {
		return 1;
	} else {
		if(b%2 == 0) {
			int half = bpow(a, b/2);
			return half*half;
		} else {
			return bpow(a, b-1)*a;
		}
	}
}

int fact(int n)
{
	if(n == 1) {
		return 1;
	} else {
		return n*fact(n-1);
	}
}

int gcd(int a, int b)
{
	if(!b) {
		return a;
	} else {
		return gcd(b, a%b);
	}
}

Array<pair<int, int> > factorize(int n)
{
	Array<pair<int, int> > res;
	for(int i = 2; i<sqrt((double)n)+1; i++) {
		if(n%i == 0) {
			pair<int, int> comp = make_pair(i, 1);
			n/=i;
			while(n%i == 0) {
				comp.second++;
				n/=i;
			}
			res.add(comp);
		}
	}

	if(n>1) {
		res.add(make_pair(n, 1));
	}
	return res;
}

int euler(int n)
{
	Array<pair<int, int> > fact = factorize(n);
	int res = 1;
	for(unsigned int i = 0; i<fact.size; i++) {
		int factor = pow((double)fact[i].first, (double)fact[i].second)-pow((double)fact[i].first, (double)fact[i].second-1);
		res*=factor;
	}
	return res;
}

int inversePrime(int a, int m)
{
	return bpow(a, m-2)%m;
}

int inverseCoprimes(int a, int m)
{
	return bpow(a, euler(m)-1)%m;
}

int inverse(int a, int m)
{
	if(gcd(a, m) == 1) {
		return inverseCoprimes(a, m);
	} else {
		assert(0);
		return -1;
	}
}

Array<int> enumerateDivisors(int n)
{
	Array<pair<int, int> > divs = factorize(n);
	vector<int> totals = vector<int>(divs.size+1);
	totals[0] = 1;
	for(unsigned int i = 1; i < divs.size+1; i++) {
		totals[i]=totals[i-1]*(divs[i-1].second+1);
	}

	Array<int> res;
	for(int i = 0; i<totals[totals.size()-1]; i++) {
		vector<int> values = vector<int>(divs.size);
		for(unsigned int j = 0; j<values.size(); j++) {
			values[j] = (i/totals[j])%(divs[j].second+1);
		}
		int r = 1;
		for(unsigned int i = 0; i<values.size(); i++) {
			r*=bpow(divs[i].first, values[i]);
		}
		res.add(r);
	}
	return res;
}

istream& operator>>( istream& in, Pair& c  )
{
	in >> c.value->description;
	c.value->key = c.value->keyF();
	return in;
}

void reverse(char *str)
{
	char temp;
	size_t len = strlen(str) - 1;
	size_t i;
	size_t k = len;

	for(i = 0; i < len; i++) {
		temp = str[k];
		str[k] = str[i];
		str[i] = temp;
		k--;
		if(k == (len / 2)) {
			break;
		}
	}
}

map<int, int> count(Array<int> a)
{
	map<int, int> res;
	for(int i = 0; i<a.size; i++) {
		res[a[i]]++;
	}
	return res;
}

void itoa(int n, char s[])
{
	int radix = 10;
	int i, sign;

	if ((sign = n) < 0)
		n = -n;
	i = 0;
	do {
		s[i++] = n % radix + '0';
	} while ((n /= radix) > 0);
	if (sign < 0)
		s[i++] = '-';
	s[i] = '\0';
	reverse(s);
}

int* vectorToArray(vector<int> v)
{
	int* a = new int[v.size()];
	for(unsigned int i = 0; i<v.size(); i++) {
		a[i] = v[i];
	}
	return a;
}

char* stringToNumber(int number)
{
	char* res = new char[100];
	itoa(number, res);
	return res;
}

int numberToString(char* str)
{
	return atoi(str);
}

int booleanAnswerBinarySearch(Array<int> params, int left, int right, bool (*f)(Array<int> params, int v))
{
	if(f(params, left) && !f(params, left-1)) {
		return left;
	}

	if(f(params, right) && !f(params, right+1)) {
		return right;
	}

	int middle = (left+right)/2;
	int g = f(params, middle);
	if(g) {
		return booleanAnswerBinarySearch(params, left, middle, f);
	} else {
		return booleanAnswerBinarySearch(params, middle+1, right, f);
	}
}

Array< Array<int> > enumerarePermutations(int n)
{
	int fac = fact(n);
	Array<int> v;
	for(int i = 0; i<n; i++) {
		v.add(i+1);
	}
	Array< Array <int> > res;
	for(int i = 0; i<fac-1; i++) {
		Array<int> c(n);
		copy(v.array, v.array + v.size, c.array);
		res.add(c);
		next_permutation(v.array, v.array + v.size);
	}
	Array<int> c(n);
	copy(v.array, v.array + v.size, c.array);
	res.add(c);
	return res;
}

Array< Array<int> > enumerarePermutations(Array<int> array)
{
	int n = array.size;
	int fac = fact(n);
	Array<int> v;
	for(int i = 0; i<n; i++) {
		v.add(array[i]);
	}
	Array< Array <int> > res;
	for(int i = 0; i<fac-1; i++) {
		Array<int> c(n);
		copy(v.array, v.array + v.size, c.array);
		res.add(c);
		next_permutation(v.array, v.array + v.size);
	}
	Array<int> c(n);
	copy(v.array, v.array + v.size, c.array);
	res.add(c);
	return res;
}

Array< Array<int> > enumerareTuples(int n, int k)
{
	int q = bpow(k, n);
	Array< Array<int> > res(q);
	for(int i = 0; i<q; i++) {
		Array<int> tuple(n);
		for(int j = 0; j<n; j++) {
			tuple[j] = (i/bpow(k, j))%k;
		}
		res[i] = tuple;
	}
	return res;
}

Array< Array<int> > enumerareTuples(int n, Array<int> array)
{
	int k = array.size;
	int q = bpow(k, n);
	Array< Array<int> > res(q);
	for(int i = 0; i<q; i++) {
		Array<int> tuple(n);
		for(int j = 0; j<n; j++) {
			tuple[j] = array[(i/bpow(k, j))%k];
		}
		res[i] = tuple;
	}
	return res;
}

Array<int> sieve(int bound)
{
	bool* array = new bool[bound+1]();
	for(int i = 2; i*i<=bound; i++) {
		if(!array[i]) {
			for(int j = i+i; j<=bound; j+=i) {
				array[j] = 1;
			}
		}
	}

	Array<int> res;
	for(int i = 2; i<=bound; i++) {
		if(!array[i]) {
			res.add(i);
		}
	}
	return res;
}

int f(int k)
{
	return k&(k+1);
}

string alignLeft(string a, int length, char ch)
{
	if(a.length() < length) {
		a = string(length - a.length(), ch) + a;
	}
	return a;
}

string decToRadix(int n, int radix)
{
	string res("");
	if(n == 0) {
		res.push_back('0');
		return res;
	}
	while(n) {
		int digit = n%radix;
		res.push_back((char)(digit + '0'));
		n/=radix;
	}
	reverse(res.begin(), res.end());
	return res;
}

int radixToDec(string s, int radix)
{
	int res = 0;
	reverse(s.begin(), s.end());
	for(int i = 0; i<s.length(); i++) {
		res+=(s[i]-'0')*bpow(radix, i);
	}
	return res;
}

/*
class item {
	int (*f)(int, int);
	int (*inverse)(int, int);

	bool operator< (item p) const {
		return min(a,b) < min(p.a,p.b);
	}
};
*/

int pl(int a, int b)
{
	return a+b;
}

int mi(int a, int b)
{
	return a-b;
}

class F
{
public:
	int (*f)(int, int);
	int (*inverse)(int, int);
	int NEUTRAL;

	F(int(*pf)(int, int), int (*pinverse)(int, int), int n) {
		f = pf;
		inverse = pinverse;
		NEUTRAL = n;
	}

	F() {
	}

	int operator()(int a, int b) {
		return f(a, b);
	}

	int inversed(int a, int b) {
		return inverse(a, b);
	}
};

class BIT
{
public:
	F f;
	Array<int> tree;
	Array<int> array;

	BIT(F func, Array<int> source) {
		Array<int> arr(source.size);
		copy(source.begin(), source.end(), arr.begin());
		array = arr;
		f = func;

		Array<int> tr(source.size);
		tree = tr;

		for(int i = 0; i<source.size; i++) {
			add(i, array[i]);
		}
	}

	void add(int i, int delta) {
		for(int u = i; u<tree.size; u = u | (u+1)) {
			tree[u]=f(tree[u], delta);
		}
	}

	int value(int l, int r) {
		return f.inversed(p(r) , p(l - 1));
	}

	int p(int v) {
		if(v < 0) {
			return 0;
		}
		if(v == 0) {
			return tree[0];
		} else {
			return f(tree[v], p((v&(v+1)) - 1));
		}
	}
};

bool delim (char c)
{
	return c == ' ';
}

bool is_op (char c)
{
	return c=='+' || c=='-' || c=='*' || c=='/' || c=='%';
}

int priority (char op)
{
	return
	    op == '+' || op == '-' ? 1 :
	    op == '*' || op == '/' || op == '%' ? 2 :
	    -1;
}

void process_op (vector<int> & st, char op)
{
	int r = st.back();
	st.pop_back();
	int l = st.back();
	st.pop_back();
	switch (op) {
	case '+':
		st.push_back (l + r);
		break;
	case '-':
		st.push_back (l - r);
		break;
	case '*':
		st.push_back (l * r);
		break;
	case '/':
		st.push_back (l / r);
		break;
	case '%':
		st.push_back (l % r);
		break;
	}
}

int calc (string & s)
{
	vector<int> st;
	vector<char> op;
	for (size_t i=0; i<s.length(); ++i)
		if (!delim (s[i]))
			if (s[i] == '(')
				op.push_back ('(');
			else if (s[i] == ')') {
				while (op.back() != '(')
					process_op (st, op.back()),  op.pop_back();
				op.pop_back();
			} else if (is_op (s[i])) {
				char curop = s[i];
				while (!op.empty() && priority(op.back()) >= priority(s[i]))
					process_op (st, op.back()),  op.pop_back();
				op.push_back (curop);
			} else {
				string operand;

				while (i < s.length() && isalnum (s[i])) {
					operand += s[i++];
				}

				--i;
				if (isdigit (operand[0]))
					st.push_back (atoi (operand.c_str()));
			}
	while (!op.empty())
		process_op (st, op.back()),  op.pop_back();
	return st.back();
}

#undef int
int main(void)
{
#define int long long int

	int n;
	cin >> n;

	char* s = new char[1000];
	cin >> s;

	int count = 0;
	for(int i = 0; i<n; i++) {

		if(s[i] == '0') {
			s[i] = '1';
			count++;

			for(int j = i-1; j>=0; j--) {
				s[j] = '0';
				count++;
			}

			println(count);

			return 0;
		}

	}

	println(n);
}


def bit_diff(n, k):
  a = []
  b = []
  while n > 0:
    a.append(n % 2)
    n //= 2
  while k > 0:
    b.append(k % 2)
    k //= 2
  if len(a) < len(b):
    a, b = b, a
  if len(a) != len(b):
    b.append(0)
  ans = 0
  for i in range(len(a)):
    ans += a[i] != b[i]
  return ans
n = input()
val = input()[::-1]
kl = int(val, 2)
print (abs(bit_diff(kl, kl + 1))


n=int(input())
s=list(input())
if "0" in s:
    print(s.index("0")+)
else:
    print(n)


def bit_count(n):
  ans = 0
  while n > 0:
    ans += n % 2
    n //= 2
  return ans
n = input()
val = input()
kl = int(val, 2)
print (abs(bit_count(kl) - bit_count(kl + 1))


n=input()
first = map(int, list(raw_input()))

count=0
plus=1
for x in range(0,len(first)):
    second[x]=(first[x]+plus)%2
    plus=(first[x]+plus)%2
for y in range(0,len(first)):
    if first[y]!=second[y]:
    count+=1
print count


#include <cstdio>
using namespace std;

int li[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int count(int n){
    int ret = 0;
    while (n > 0) {
        ret += li[n%10];
        n /= 10;
    }

    return ret;
}

int main() {
    int a, b;
    scanf("%d%d", &a, &b);

    int cnt = 0;
    for (int i = a; i <= b; i++) {
        cnt += count(i);
    }

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

    return 0;
}


l = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
a, b = map(int, raw_input().split())
res = 0;
for i in range(a, b+1):
    while i > 0:
        res += l[i%10]
        i /= 10
print res


n=input()
if n==2:
    print("2")
else
    print("1")


x = input()

if x<3:
    print x
else
    print "1"


k = int(input())

if k==2:
    print(2)

else(print(1))


 n, k, l, c, d, p, nl, np = map(int,raw_input().split())
 line = []
 every1 = k*l / nl
 every2 = c*d
 every3 = p/np
 line.append(every1)
 line.append(every2)
 line.append(every3)

 line = sorted(line)

 print line[0]/n


n, k, l, c, d, p, nl, np = [int(i) for i in input().split()]
print(min((k*l)//(n*nl), c*d//n, p//(n*np))


n=input()
mp=''
def rec(s):
    global mp
    if len(s) == 2:
        if s==s[::-1]:
            mp = max(mp, s)
        mp = max(mp, max(s[1], s[0]))
        return
    for i in range(1, len(s)+1):
        rec(s[:i-1]+s[i:])
    if s==s[::-1]:
        mp = max(mp, s)
rec(n)
print(mp)


n=input()
mp=''
def rec(s):
    global mp
    if s == '':
        return
    for i in range(1, len(s)):
        rec(s[:i-1]+s[i:])
    if s==s[::-1]:
        mp = max(mp, s)
rec(n)
print(mp)


n=input()
lst=[]
from itertools import permutations
for i in range(1,len(n)):
    c=permutations(n,i)
    for j in c:
        if(j==j[::-1]):
            lst.append(j)
lst.sort()
s=''
for i in lst[-1]:
    s=s+i
print(s)


import sys
sys.setrecursionlimit(1000000)

def proov(st):
    l=[i for i in st]
    g=l[:]
    g.sort()
    if g==l:
        return True
    else:
        return False

def rec(i,j):
    global l
    if l[i][j]=='':
        if s[i]==s[j]:
            d=s[i]
            d+=str(rec(i+1,j-1))
            d+=s[i]

            if proov(d):
                l[i][j]=d
        else:
            t=rec(i+1,j)
            t2=rec(i,j-1)
            if proov(t)==False:
                t=''
            if proov(t2)==False:
                t2=''
            if len(t)>len(t2):
                l[i][j]=t
            else:
                l[i][j]=t2
    return l[i][j]

s=input()
n=len(s)
l=[[0]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if i==j:
            l[i][j]=s[i]
        elif i<j:
            l[i][j]=''
        else:
            l[i][j]=0
rec(0,n-1)

print(l[0,n-1])


from itertools import permutations
s=input()
d={}
c=1
m=-1
l=[]
d={}
for i in range(len(s)):
    l.append(list(permutations(s,i+1)))
for i in range(len(l)):
    for j in range(len(l[i])):
        l[i][j]=''.join(l[i][j])
for i in l:
    for j in i:
        if(j==j[::-1]):
            if(j not in d):
                d[j]=0
print(max(d))


// Program to print BFS traversal from a given source vertex. BFS(int s)
// traverses vertices reachable from s.
#include<iostream>
#include <list>

using namespace std;

// This class represents a directed graph using adjacency list representation
class Graph
{
    int V;    // No. of vertices
    list<int> *adj;    // Pointer to an array containing adjacency lists
public:
    Graph(int V);  // Constructor
    void addEdge(int v, int w); // function to add an edge to graph
    void BFS(int s);  // prints BFS traversal from a given source s
};

Graph::Graph(int V)
{
    this->V = V;
    adj = new list<int>[V];
}

void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w); // Add w to v�s list.
}

void Graph::BFS(int s)
{
    // Mark all the vertices as not visited
    bool *visited = new bool[V];
    for(int i = 0; i < V; i++)
        visited[i] = false;

    // Create a queue for BFS
    list<int> queue;

    // Mark the current node as visited and enqueue it
    visited[s] = true;
    queue.push_back(s);

    // 'i' will be used to get all adjacent vertices of a vertex
    list<int>::iterator i;

    while(!queue.empty())
    {
        // Dequeue a vertex from queue and print it
        s = queue.front();
        cout << s << " ";
        queue.pop_front();

        // Get all adjacent vertices of the dequeued vertex s
        // If a adjacent has not been visited, then mark it visited
        // and enqueue it
        for(i = adj[s].begin(); i != adj[s].end(); ++i)
        {
            if(!visited[*i])
            {
                visited[*i] = true;
                queue.push_back(*i);
            }
        }
    }
}

// Driver program to test methods of graph class
int main()
{
    // Create a graph given in the above diagram
    Graph g(4);
    g.addEdge(0, 1);
    g.addEdge(0, 2);
    g.addEdge(1, 2);
    g.addEdge(2, 0);
    g.addEdge(2, 3);
    g.addEdge(3, 3);

    cout << "Following is Breadth First Traversal (starting from vertex 2) \n";
    g.BFS(2);

    return 0;
}


n = str(raw_input())
dot = n.index('.')
e_idx = n.index('e')
space = int(n[e_idx+1:])

n = n[:dot] + n[dot+1:e_idx]

if (space < (e_idx - dot)):
	n = n[:dot+space] + '.' + n[dot+space:]
else:
	space -= (e_idx-dot)
	while (space >= 0):
		n = n + '0'
		space-=1

if (n.endswith('.')):
	n = n[:len(n)-1]

try:
	dot = n.index('.')
	while (n.startswith('0') and not (n.startswith('0.'))):
		n = n[1:]
    dot = n.index('.')
    if (n[:dot+1] == '0'):
        n = n[:dot-1]
except ValueError:
	while (n.startswith('0')):
		n = n[1:]

print n


val = raw_input()
ePos = val.find('e')
dotPos = val.find('.')
a = val[:dotPos]
b = val[dotPos+1:ePos]
exponent = int(val[ePos+1:])
if exponent > len(b):
	b += '0'*(exponent - len(b))
if exponent < len(b):
	b = b[:exponent] + '.' + b[exponent:]
b = a + b
if b == '0.0':
	print 0
elif b[1] != '.':
	print b.lstrip('0')
else
	print b


from decimal import *
d = Decimal(input())
if int(d) == d:
    print('%d' % d)
print d


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

// m is size of coins array (number of different coins)
int minCoins(int coins[], int m, int V)
{
    // table[i] will be storing the minimum number of coins
    // required for i value.  So table[V] will have result
    int table[V+1];

    // Base case (If given value V is 0)
    table[0] = 0;

    // Initialize all table values as Infinite
    for (int i=1; i<=V; i++)
        table[i] = INT_MAX;

    // Compute minimum coins required for all
    // values from 1 to V
    for (int i=1; i<=V; i++)
    {
        // Go through all coins smaller than i
        for (int j=0; j<m; j++)
          if (coins[j] <= i)
          {
              int sub_res = table[i-coins[j]];
              if (sub_res != INT_MAX && sub_res + 1 < table[i])
                  table[i] = sub_res + 1;
          }
    }
    return table[V];
}

// Driver program to test above function
int main()
{
    int coins[] =  {10,100,20, 5, 1};
    int m = sizeof(coins)/sizeof(coins[0]);
    int V = 125;
    cin>>V;

    cout     << minCoins(coins, m, V);
    return 0;
}


def s(a):
    c=[100,20,10,5,1]
    t=0
    for i in c:
        if a>=i:
            dt=a//c:
            dt+=t
            a-=(dt*i)
    return t
a=int(input())
print(d(a))


n = int(input())
coins = [100, 20, 10, 5, 1]
total_coin_count = 0
for coin in coins:
    if n >= coin:
        this_coin_count = n/coin
        total_coin_count += this_coin_count
        n -= (this_coin_count * coin)
return total_coin_count


n = int(input ())

i = 0

a[100, 20, 10, 5, 1]

for el in a:
    if n >= el :
    i += n // el
    n = n % el

print(i)


a,b=map(int,input().split())
m=[0]*a
m1=[]
for i in range(b):
    m1.append(list(map(int,input().split())))
    m[m1[-1][1]-1]=b+1
    m1[-1].append(i+1)
m1.sort(key = lambda x:x[1]-x[0])
for i in m1:
    c=i[2]
    for j in range(i[0]-1,i[1]+1):
        if m[j] == 0:
            m[j]=i[3]
            c-=1
        if c == 0:
            break
    if c != 0:
        m1.sort()
        m=[0]*a
        for i in m1:
            m[i[1]-1] = b+1
        for i in m1:
            c=i[2]
            for j in range(i[0]-1,i[1]+1):
                if m[j] == 0:
                    m[j]=i[3]
                    c-=1
                if c == 0:
                    break
            if c != 0:
                m=False
                break
        break
if m == False:
    print(-1)
else:
    print(*m)


rt = lambda: map(int, input().split())
a, s = rt()
w = sorted(([*rt()] + [i + 1] for i in range(s)), key=lambda x: x[1])
q = [0] * a
for i in w:
    q[i[1] - 1] = s + 1
    for i in range(i[0] - 1, i[1] - 1):
        if not q[i]:
            q[i] = i[3]
            i[2] -= 1
            if not i[2]:
                break
    if i[2]:
        print(-1)
        exit()
print(*q)


 rd = lambda: map(int, input().split())
n, m = rd()
a = sorted(([*rd()] + [i + 1] for i in range(m)), key=lambda x: x[1])
r = [0] * n
for x in a:
    r[x[1] - 1] = m + 1
    for i in range(x[0] - 1, x[1] - 1):
        if not r[i]:
            r[i] = x[3]
            x[2] -= 1
            if not x[2]:
                break
    if x[2]:
        print(-1)
        exit()
print(*r)


n,m = map(int,raw_input().split())
L = []
for i in range(m):
    a, b, c = map(int, input().split())
    L.append([b, a, c, i])
L.sort()

M = [-1 for i in range(n + 1)]
for i in range(m):
    M[L[i][0]] = m + 1
for i in range(1, n + 1):
    if M[i] == -1:
        f = False
        for j in range(m):
            if L[j][1] <= i and L[j][2] > 0 and i < L[j][0]:
                M[i] = L[j][3] + 1
                L[j][2] -= 1
                f = True
                break
        if not(f):
            M[i] = 0
f = True
for j in range(m):
    if L[j][2] > 0:
        f = False
if f:
    print (*M[1:])
else:
    print -1


n,m = map(int,raw_input().split())
L = []
for i in range(m):
    a, b, c = map(int, input().split())
    L.append([b, a, c, i])
L.sort()

M = [-1 for i in range(n + 1)]
for i in range(m):
    M[L[i][0]] = m + 1
for i in range(1, n + 1):
    if M[i] == -1:
        f = False
        for j in range(m):
            if L[j][1] <= i and L[j][2] > 0 and i < L[j][0]:
                M[i] = L[j][3] + 1
                L[j][2] -= 1
                f = True
                break
        if not(f):
            M[i] = 0
f = True
for j in range(m):
    if L[j][2] > 0:
        f = False
if f:
    print *M[1:]
else:
    print -1


import math
n,k=input().split()
N,n=int(n),int(n)
k=int(k)
count,ans=0,0
while count<k:
    if n%10==0: count+=1
    else: ans+=1
    n//=10
if n==0: print(int(math.log10(N)))
else print(ans)


number,k = input().split(' ')

if(len(number)<=int(k)):
    print(len(number)-1)
else:
    countZero = 0
    countDelete = 0
    for i in range(1,len(number)+1):
        if(countZero==int(k)):
            break
        if(number[-i]=='0'):
            countZero+=1
        else:
            countDelete+=1
    if(len(number)-(countDelete)<int(k)+1)
    print(countDelete)


s = raw_input()
n = s.split()[0]
k = int(s.split()[1])
ret = 100
for mask in xrange(2 ** len(n)):
    t = ""
    for i in xrange(len(n)):
        if mask & (2**i):
            t += s[i]
    if int(t) % (10**k) == 0:
        ret = min(ret, len(t)
print ret


[a,c]=[x for x in input().split()]
b=int(c)
z=0
d=0
for i in range(len(n)):
    if n[len(n)-i-1]=='0':
        z+=1
        if z==b:
            if
            print(d)
            exit()
    else:
        d+=1
        if i==len(n)-1:
            print(len(n)-1)
            exit()


n,k=list(map(int,input().split()))
if n<pow(10,k):
    print(len(str(n))-1)]
elif list(str(n)).count("0")<k:
    print(len(str(n))-1)]
else:
    n=str(n)
    n=n[::-1]
    x=0
    p=0
    for y in n:
        if p!=k:
            if y=="0":
                x-=1
                p+=1
            else:
                x-=1
                pass
        else:
            break
    lk=0
    n=n[::-1]
    for item in n[x:]:
        if item!="0":
            lk+=1
        else:
            pass
    print(lk)


from sys  import stdin,stdout
from math import gcd
st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

def HII(p,c):
    x=''
    j=0
    for i in range(len(p)):
        if p[i]=='4':
            if c[j]!='4':
                return False

            x+=p[i]
            j+=1
        elif p[i]=='7':
            if c[j]!='7':
                return False
            j+=1
            x+=p[i]

    return x==c

def solve():
    a,b=mp()
    c=str(b)
    a+=1
    x,y=c.count('4'),c.count('7')
    while True:
        p=str(a)
        if HII(p,c):
            pr(p)
            return
        a+=1

for _ in range(1):
    solve()


A , B = raw_input().spilt();
a, b = map(int, [A, B]);
c = a + 1;
while ''.join (ch for ch in str(c) if ch in '47') != B:
    c += 1;
print(c);


a, b = input().split()
for i in range(max(int(a) + 1, int(b)), 999999):
  if ''.join(c for c in str(i) if c in ('4,7')) == b:
    return print(i)


a, b = input().split()
    for i in range(max(int(a) + 1, int(b)), 999999):
        if ''.join(c for c in str(i) if c in ('4,7')) == b:
            return print(i)


a,b=map(int,raw_input().split())
sb=str(b)
for i in xrange(a+1,10**5+1):
	s=str(i)
	s2=''
	for x in s:
		if x=='4' or x=='7':
			s2+=x
	if s2==sb:
		print i
		exit()


import sys

b, d = [int(s) for s in sys.stdin.readline().split(' ')]

def pf(d):
    l = []
    i = 2
    while i * i <= d:
        if d % i == 0:
            k = 1
            while d % i == 0:
                d /= i
                k *= i
            l.append(k)
        i += 1
    if d > 1:
        l.append(d)
    return l

def typ(b, d):
    if (b ** 7) % d == 0:
        i, bb = 1, b
        while bb % d != 0:
            i, bb = i + 1, bb * b
        return (2, i)
    elif (b - 1) % d == 0:
        return 3
    elif (b + 1) % d == 0:
        return 11
    else:
        p = pf(d)
        if p != [d] and all(typ(b, f) != 7 for f in p):
            return 6
        else:
            return 7

t=typ(b,d)
if isinstance(t, int):
    print "%d-type" % t
else:
    print "%d-type" % t[0]
    print t[1]


import sys
from random import randint
from math import sqrt

mul=[]
rand=[]
SIZE = 32

def checkTypeZwei(base,div):
	for i in xrange(SIZE):
		if(int(mul[i])%div==0):
			return i
	return -1

def checkTypeDrei(base,div):
	for num in rand:
		sum=0
		for ch in num:
			sum+=ch
		if(sum%div!=0):
			#print sum,div
			return False

	return True

def checkTypeElf(base,div):
	for i in xrange(SIZE):
		num=rand[i]
		eve=0
		odd=0
		ind=0
		num=num[::-1]
		for ch in num:
			if(ind&1):
				odd+=ch
			else:
				eve+=ch
			ind+=1

		if(odd!=eve and abs(odd-eve)%div!=0 ):
			return False

	return True

def checkTypeSechs(base,div):
	factor=[]
	for i in xrange(2,div+1):
		if(div%i==0):
			factor.append(i)
			while(div%i==0):
				div/=i
	ans=True
	#print factor
	if(len(factor)<2):
		return False
	for num in factor:
		if(checkTypeZwei(base,num)!=-1 or checkTypeDrei(base,num) or checkTypeElf(base,num)):
			ans=True
		else:
			ans=False
			break;
	return ans

def xBase(num,base):
	res=[]
	while(num):
		tmpNum=num%base
		tmpList=[]
		tmpList.append(tmpNum)
		tmpList.extend(res)
		res=tmpList
		num/=base
	return [0] if(res=='') else res

if(__name__=='__main__'):

	instr=raw_input()
	instr=instr.split()
	base=int(instr[0])
	div=int(instr[1])

	for i in xrange(SIZE):
		mul.append(str(base**i))

	for i in xrange(SIZE):
		num=randint(0,1<<16)
		num*=div
		#print xBase(num,base)
		rand.append(xBase(num,base))
	type=7
	leng=-1
	if(type==7):
		leng=checkTypeZwei(base,div)
		if(leng!=-1):
			type=2

	if(type==7):
		if(checkTypeDrei(base,div)):
			type=3

	if(type==7):
		if(checkTypeElf(base,div)):
			type=11

	if(type==7):
		if(checkTypeSechs(base,div)):
			type=6

	print(str(type)+'-type')
	if(type==2):
		print leng


from fractions import gcd
b,D=map(int,raw_input().split())
a=200*[0]
z=200*[0]
for d in range(2,101):
	c=0
	t=d
	while gcd(b,t)>1:
		t/=gcd(b,t)
		c+=1
	if t==1:
		a[d]=2
		z[d]=c
		continue
	if b%d==1:
		a[d]=3
		continue
	if (b+1)%d==0:
		a[d]=11
		continue
	a[d]=7
	for i in range(2,d):
		if d%i==0 and gcd(i,d/i)==1 and a[i]!=7 and a[d/i]!=7:
			a[d]=6
print "%d-type"%a[D]
if a[D]==2:
	print z[D]


b,d=map(int,raw_input().split())
for i in xrange(1,10):
    if (b**i)%d==0:
        print "2-type"
        print i
        exit()
if (b-1)%d==0:
    print "3-type"
elif (b+1)%d==0:
    print "11-type"
else:
    for i in xrange(2,d+1):
        if d%i==0:
            x=1
            while d%i==0: d/=i; x*=i
            if (b**10)%x!=0 and (b+1)%x!=0 and (b-1)%x!=0:
                print "7-type"
                exit()
    print "6-type"


import sys

b, d = [int(s) for s in sys.stdin.readline().split(' ')]

def pf(d):
    l = []
    i = 2
    while i * i <= d:
        if d % i == 0:
            while d % i == 0: d /= i
            l.append(i)
    if i > 1:
        l.append(i)
    return l

def typ(b, d):
    if (b ** 7) % d == 0:
        i, bb = 1, b
        while bb % d != 0:
            i, bb = i + 1, bb * b
        return (2, i)
    elif (b - 1) % d == 0:
        return 3
    elif (b + 1) % d == 0:
        return 11
    else:
        p = pf(d)
        if p and all(typ(b, f)[0] != 7 for f in p):
            return 6
        else:
            return 7

t=typ(b,d)
if isinstance(t, int):
    print "%d-type" % t
else:
    print "%d-type" % t[0]
    print t[1]


n = int(input())

numbers = list(map(int, input().split()))

if all(numbers[x] == 0 for x in range(n)):
    print("NO")
else:
    print("YES")
    if sum(numbers):
        print("1\n1 {}".format(n))
    else:
        i = 0
        while sum(numbers[0:i+1]) == 0:
            ++i
        print("2\n{} {}\n{} {}".format(1, i+1, i+2, n))


import itertools

def split_array(array):
    split_index = list(range(1, len(array)))
    for i in range(len(array)):
        for each_comb in itertools.combinations(split_index, i):
            each_comb = list(each_comb)
            each_comb.insert(0, 0)
            each_comb.insert(len(each_comb), len(array))

            index = []
            arrays = []
            for i in range(len(each_comb) - 1):
                index.append([each_comb[i], each_comb[i + 1]])
                arrays.append(array[each_comb[i] : each_comb[i + 1]])
            if not 0 in [sum(each_arr) for each_arr in arrays]:
                return index
    return None

if __name__ == '__main__':
    num = int(input())
    array = [int(x.strip()) for x in input().split(' ')]

    index = split_array(array)
    if index:
        print('YES')
        print(len(index))
        for each in index:
            print('%d %d' % (each[0] + 1, each[1]), end='')
            print()
    else:
        print('NO')


#! /usr/bin/env python

import os
import sys
from math import *
from scipy import stats
import numpy as np
from decimal import *
from collections import Counter
import timeit
import time
import matplotlib.pyplot as plt
import re
from itertools import permutations
from itertools import combinations

# if __name__ == '__main__':

	n, A = int(input()), list(map(int, input().split()))

	allZero = True
	sum1 = 0
	for i in range(n):
		sum1 = sum1 + A[i]
		if(A[i] != 0):
			allZero = False

	if(allZero == True):
		print("NO")
	elif(sum1 == 0):
		for i in range(n):
			if(A[i] != 0):
				break
		print("YES")
		print("2")
		print("1 " + str(i+1))
		print(str(i+2) + " " + str(n))
	else:
		print("YES")
		print("1")
		print("1 " + str(n))


def main():
	n = input()
	L = [int(x) for x in input().split()]
	(boolean, lists) = solver(L)
	print(boolean)
	if boolean == 'YES':
		print(len(lists))
		for (l, r) in lists:
			print(l, r)

def solver(L):
	if L == [0] * len(L):
		return ('NO', [])
	else:
		start = firstNonZero(L)
		end = lastNonZero(L)
		i = start
		lists = []
		#while i < end + 1:
		total = sum(L[start:end+1])
		if total != 0:
			return ('YES', [(1, len(L)])
		else:
			return ('YES', [(1, end), (end + 1, len(L))])
		# total = 0
		# for j in range(i, end + 1):
		# 	total +=

def firstNonZero(L):
	for i in range(len(L)):
		if L[i] != 0:
			return i
	assert(False)

def lastNonZero(L):
	for i in range(len(L) - 1, -1, -1):
		if L[i] != 0:
			return i
	assert(False)

#print(solver([1, 2, 3, -5]))
main()


# -*- coding: utf-8 -*-

n = int(raw_input())
temp = raw_input()

cnt = 0
data = temp.split()

temp = 0

for i in range(n):
    data[i]=int(data[i])
    cnt += data[i]
    return ;

if cnt!=0:
    print "YES"
    print "1\n%d %d"%(1,n)

cnt2 = 0
tar = 0
for i in range(n):
    cnt2 += data[i]
    if cnt-cnt2 != 0 and cnt2 !=0:
        tar = i+1
        break

if tar:
    print "YES"
    print "2\n%d %d\n%d %d"%(1,tar,tar+1,n)
else:
    print "NO"


a, b = input().split()
if int(a)+int(b)==3:
    print('3')
if int(a)+int(b)==4:
    print('2')
if int(a)+int(b)==5:
    print('1')


inp = open('input.txt', 'r')
out = open('output.txt', 'w')
a,b = inp.read(3).split(' ')
out.write(str(int(a) ^ int(b)))
out.close()
inp.close()


a = input()
b = input()

c = 6 - a - b
print(`c`)


N, A = map(int, input().split())
problems = []
for i in range(N):
    a, b = map(int, input().split())
    problems.append((a, b))
problems.sort()
ans = 0
while ans < N and A >= problems[ans][0]:
    A += problems[ans][1]
    ans += 1
print(ans)


#   Codeforces
#   #509A   -  Maximum in Table
#   http://codeforces.com/problemset/problem/509/A
#   12/01/2019
#   Nilton G. M. Junior

def fact(n):
    return 1 if n == 0 else n * fact(n - 1)

def get_max(mat_order):
    if mat_order == 1:
        return 1
    else
        return fact(get_max(mat_order - 1)) / (fact(get_max(mat_order - 1)) ** 2)

if __name__ == '__main__':
    mat_order = int(input())
    print(get_max(mat_order))


from math import factorial
n=int(input())
print(factorial(2n-2)/(factorial(n-1))**2)


import math
n = int(input())
print(factorial(2*(n-1))


import math
n = int(input())
print(factorial(2*(n))


n=int(raw_input())
m=[[1]*n,[1]*n]
while n-1>=0:
    a=n%2;b=(n-1)%2;
    for i in xrange(1,n):
        for j in xrange(n):
            m[b][j]+=m[a][i]
    n--
print m[0][n-1]


n = int(input())
l = []
res = []
def foo(k):
    global l
    global res
    if k == 0:
        if len(l) > len(res):
            res = l
        l = list()
        return
    for i in range(k // 2 + 1, k + 1):
        l.append(i)
        foo(k - i)
foo(n)
print(len(res))
for i in res:
    print(i, end=" ")


from itertools import combinations
n = int(input())
ls = [x for x in range(1, min(45, n+1))]
try:
    for i in range(n, 0, -1):
        cs = list(combinations(ls, min(45, i)))
        for c in cs:
            if sum(c) == n:
                raise
except:
    print(len(c), '\n' + ' '.join(map(str, c)))


from math import sqrt
n=int(input())
x=[]
y=[]
sumo=0
i=0
f=0
while(f==0 ):
    i=i+1
    ln=n
    n=n-i
    y.append(i)
    if(n in y):
        break
    else:
        x.append(i)
x.append(ln)
print(len(x))
for i in x:
    print(i,end=' ')


n = int(raw_input())
sum = 0;
i = 1;
a = []
while(sum <= n):
	if(sum + i <= n):
		sum += i;
	else:
		break;
	a.append(i);
	i+=1;

rem = n - sum
a[0] += rem;
print len(a)
print ' '.join([str(i) for i in a]);


n=int(input())
a=[]
i=1
while(i<=n):
     a.append(i)
     n-=i
     i+=1
a[-1]+=n
print(len(a))
print(*a)//*a give only value


line = raw_input()
a1,b1 = [int(x) for x in line.split()]
line = raw_input()
a2,b2 = [int(x) for x in line.split()]
line = raw_input()
a2,b2 = [int(x) for x in line.split()]
if a2+a3<=a1 and b2+b3<=b1 or a2+a3<=b1 and b2+b3<=a1 or a2+b3<=a1 and b2+a3<=b1 or a2+b3<=b1 and b2+a3<=a1:
    print 'YES'
else:
    print 'NO'


import sys
def main():
    x = []
    n,m = [int(i) for i in input().split()]
    a1,b1 = [int(i) for i in input().split()]
    a2,b2 = [int(i) for i in input().split()]
    ok = lambda a1,b1,a2,b2 : a1 + a2 <= x[0][0] and max(b1,b2)<= x[0][1] or b1 + b2 <= x[0][0] and max(a1,a2)<= x[0][1]
    print('YES' if ok(a1, c1, a2, c2) or ok(a1, c1, c2, a2) or ok(c1, a1, a2, c2) or ok(c1, a1, c2, a2) else 'NO')
main()


def main():
    liste = []
    a,b = map(int,input().split())
    a1,b1 = map(int,input().split())
    a2,b2 = map(int,input().split())
    if (max(a1,a2)<=a and b1+b2<=b) or (max(b1,a2)<=a and (a1+b2)<=b) or (max(a1,b2)<=a and b1+a2<=b) or (max(b1,b2)<=a and a1+a2<=b) :
        return "YES"
    if (max(a1,a2)<=b and b1+b2<=a) or (max(b1,a2)<=b and (a1+b2)<=a) or (max(a1,b2)<=b and b1+a2<=a) or (max(b1,b2)<=b and a1+a2<=a):
        return "YES"
    return "NO"
for loop in range(100):
    print(main())


b=raw_input().split()
a1=raw_input().split()
a2=raw_input().split()
a=int(a1[0])
b=int(a1[1])
c=int(a2[0])
d=int(a2[1])
e=int(b[0])
f=int(b[1])

def fitsin(a1,a2,b1,b2):
    return max(b1,b2)<=max(a1,a2) and min(b1,b2)<=min(a1,a2)

if fitsin(f-a,e,c,d) or fitsin(e-b,f,c,d) or fitsin(f-b,e,c,d) or fitsin(e-a,f,c,d):
    print "YES"
else:
    print "NO"


standW, standH = map(int, raw_input().split(","))
p1W, p1H = map(int, raw_input().split(","))
p2W, p2H = map(int, raw_input().split(","))

def isFit(w1,h1,w2,h2):
    return (w1+w2<=standW and max(h1,h2)<=standH) or (w1+w2<=standW and max(h1,h2)<=standW);

if isFit(p1W, p1H, p2W, p2H) or isFit(p1W, p1H, p2H, p2W) or isFit(p1H, p1W, p2W, p2H) or isFit(p1H, p1W, p2H, p2W):
    print "YES";
else:
    print "NO";


def manners(s):
    if s[0] != 'a' or (s[1] != 'a' and s[1] != 'b'):
        return 'NO'
    else:
        for i in range(2, len(s)):
            b = max(ord(s[i-2]), ord(s[i-1]))
            if ord(s[i]) - b > 1:
                return 'NO'
        return 'YES'

print(manners(input()))


s = raw_input()
p = 1

for c in s:
    q = ord(c) - ord('a')
    if q == p:
        p += 1
    elif q > p:
        print("NO")
        exit()

print("YES")


n=input()
s=[int(i) for i in range(ord('a'),ord('z')+1)]
s=s[::-1]
for i in n:
    a=ord(i)
    if a==s[-1]:
        s.pop()
    elif a>s[-1]:
        print('NO')
        exit()
print('YES')


class GlobalMembers(object):
	def __init__(self):
		self._maxn = 1e6 + 100
		self._a = System.String(Array.CreateInstance(Char, 1005))
		self._vis = Array.CreateInstance(int, self._maxn)

	def Main():
		tempVar = ConsoleInput.scanfRead()
		if tempVar != None:
			self._a = Byte.parseByte(tempVar)
		n = self._a.length()
		flag = 0
		ans = 'a'
		self._vis[0] = 1
		if self._a.charAt(0) != 'a':
			flag = 1
		i = 0
		while i < n:
			if self._vis[self._a.charAt(i) - 'a'] == 0:
				if self._a.cha


 a=list(input())
b=[]
for i in a:
    if i not in b:
        b.append(i)
for i in range(len(b)):
    if (ord(b[i])-ord('a'))!=i:
        exit(print('NO'))
print('YES')


/*package whatever //do not write package name here */

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

class GFG {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		if(k == 1) System.out.println(n);
		else {
		    int count = 1, x = 1;
		    while(x < n) {
		        x = (int)Math.pow(2, count) + x;
		        count++;
		    }
		    System.out.println(x);
		}
	}
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,k;
int main()
{
    scanf("%lld%lld",&n,&k);
    ll len = 0;
    ll sum = 0;
    while(n)
    {
        n/=2;
        len++;
    }
    ll p = 1;
    for(int i=0;i<len;i++)
    {
        sum += p;
        p *= 2;
    }

    if(k>1)
        printf("%lld",sum);
    else
        printf("%lld",n);
    return 0;
}


n, k = map(int,input().split())
if k == 1:
  print(n)
else:
  i = 0
  while (1 << i) < n: i++
  print (1 << i)


By striker_1996, contest: Codeforces Round #456 (Div. 2), problem: (B) New Year's Eve, Wrong answer on test 20, #

n,k=raw_input().split()
n,k=int(n),int(k)
if n==1:
    print(n)

else:
    while num<=n:
        num=num*2
    print(num-1)


/*package whatever //do not write package name here */

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

public class GFG {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		if(k == 1) System.out.println(n);
		else {
		    int count = 1, x = 1;
		    while(x < n) {
		        x = (int)Math.pow(2, count) + x;
		        count++;
		    }
		    System.out.println(x);
		}
	}
}


P = ["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]
def main():
   n = input()
   s = raw_input()
   D = {}

   for i in xrange(n):
      if s[i] == '.': continue
      D[i] = s[i]

   #print D
   if n == 7:
      for i in xrange(8):
         if len(P[i]) != n: continue
         for l in D:
            r = False
            if D[l] != P[i][l]:
               r = True
               break
         if r: continue
         break

   if n == 6: ans = P[3]
   elif n == 8: ans = P[8]
   else: ans = P[i]
   print ans

if __name__ == '__main__':
   main()


n = input()
poke_list = []
pokecross = raw_input("")
if n==6:
    print "espeon"
elif n==7 and pokecross[3] != 'r':
    poke_list.append("sylv")
    poke_list.append("leaf")
    poke_list.append("glac")
    poke_list.append("jolt")
    poke_list.append("umb")
    poke_list.append("fla")
    for pokename in poke_list:
        i = 0;
        for character in pokename:
            if pokecross[i] != character:
                i=i+1
            elif (i==2 and pokecross[i] == 'a') or (i==1 and pokecross[i] =='l'):
                i=i+1
            elif pokename[0]=='f' of pokename[0]=='u':
                print pokename + "reon"
                break
            else:
                print pokename + "eon"
                break
else:
    print "vaporeon"


n,s=input(),raw_input()
for name in ["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]:
    if len(name) == n and all(s[i]=='.'or s[i] == name[i] for i in range(n))
        print name


n,s=input(),raw_input()
for name in ["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]:
    if len(name) == n and all(s[i]=='.'|| s[i] == name[i] for i in range(n))
        print name


import re

n = input()
s = raw_input()
dict = ["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]

for i in dict:
    result = re.match(s, i, 0)
    if result:
        print i
        break


import os,sys
####Inna and Pink Pony: 374A http://codeforces.com/problemset/problem/374/A

###Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n*m chessboard, a very tasty candy and two numbers a and b.
###Dima put the chessboard in front of Inna and placed the candy in position (i,j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:
###move the candy from position (x,y) on the board to position (x-a,y-b);
###move the candy from position (x,y) on the board to position (x-a,y+b);
###move the candy from position (x,y) on the board to position (x+a,y-b);
###move the candy from position (x,y) on the board to position (x+a,y+b);

###Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.
###nna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,j) to one of the chessboard corners. Help them cope with the task!

###input
###The first line of the input contains six integers n,m,i,j,a,b
###You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right.
###The corner are (1,m), (n,1), (n,m), (1,1)

###output
###In a single line print a single integer  -- the minimum number of moves needed to get the candy.
###If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes.

###solve: bfs
def run():
    n, m, i, j, a, b = map(int, raw_input().split())

    visited = {}
    corners = [(1,m), (n,1), (n,m), (1,1)]
    depths = list()
    que = list()

    que.append((i,j))
    depths.append(0)
    visited[(i,j)] = True
    ###bfs
    while len(que) > 0:
        curPos = que.pop(0)
        curDpth = depths.pop(0)
        if curPos in corners:
            print curDpth
            return
        x = curPos[0]
        y = curPos[1]
        for pos in [(x-a,y-b), (x+a,y-b), (x-a,y+b), (x+a,y+b)]:
            if pos[0]<1 or pos[1]<1 or pos[0]>n or pos[1]>m:
                continue
            if pos in visited:
                continue
            visited[pos] = True
            que.append(pos)
            depths.append(curDpth+1)
    print "Poor Inna and pony!"
    return
################################################################################
run()


import os,sys
####Inna and Pink Pony: 374A http://codeforces.com/problemset/problem/374/A

###Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n*m chessboard, a very tasty candy and two numbers a and b.
###Dima put the chessboard in front of Inna and placed the candy in position (i,j) on the board. The boy said he would give the candy if it reaches one of the corner cells of the board. He's got one more condition. There can only be actions of the following types:
###move the candy from position (x,y) on the board to position (x-a,y-b);
###move the candy from position (x,y) on the board to position (x-a,y+b);
###move the candy from position (x,y) on the board to position (x+a,y-b);
###move the candy from position (x,y) on the board to position (x+a,y+b);

###Naturally, Dima doesn't allow to move the candy beyond the chessboard borders.
###nna and the pony started shifting the candy around the board. They wonder what is the minimum number of allowed actions that they need to perform to move the candy from the initial position (i,j) to one of the chessboard corners. Help them cope with the task!

###input
###The first line of the input contains six integers n,m,i,j,a,b
###You can assume that the chessboard rows are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right.
###The corner are (1,m), (n,1), (n,m), (1,1)

###output
###In a single line print a single integer  -- the minimum number of moves needed to get the candy.
###If Inna and the pony cannot get the candy playing by Dima's rules, print on a single line "Poor Inna and pony!" without the quotes.

###solve: bfs
def run():
    n, m, i, j, a, b = map(int, raw_input().split())

    visited = [[0 for y in range(m+1)] for x in range(n+1)]
    corners = [(1,m), (n,1), (n,m), (1,1)]
    depths = list()
    que = list()

    if (i,j) in corners:
        print 0
        return
    que.append((i,j))
    depths.append(0)
    visited[i][j] = 1
    ###bfs
    while len(que) > 0:
        curPos = que.pop(0)
        curDpth = depths.pop(0)
        x = curPos[0]
        y = curPos[1]
        for pos in [(x-a,y-b), (x+a,y-b), (x-a,y+b), (x+a,y+b)]:
            if pos[0]<1 or pos[1]<1 or pos[0]>n or pos[1]>m or 1 == visited[pos[0]][pos[1]]:
                continue
            if pos in corners:
                print curDpth+1
                return
            visited[pos[0]][pos[1]] = 1
            que.append(pos)
            depths.append(curDpth+1)
    print "Poor Inna and pony!"
    return
################################################################################
run()


n,m,x,y,a,b = map(int,raw_input().split())

ans = -1
for c in [(1,m),(n,1),(n,m),(1,1)]:
    dx = abs(x - c[0])
    dy = abs(y - c[1])
    if dx==0 and dy==0:
        print 0
        exit(0)
    elif dx%a==0 and dy%b==0 and (dx/a)%2==(dy/b)%2:
        if ans==-1:
            ans = max(dx/a,dy/b)
        else:
            ans = min(ans,max(dx/a,dy/b))

if (n-x<a and stx-1<a) or (m-sty<b and sty-1<b):
    ans = -1
if ans!=-1:
    print ans
else print "Poor Inna and pony!"


inf = 1000 * 1000 * 1000
def calc(x, y):
	if(x % a != 0 or y % b != 0):
		return inf
	if(x == 0 && y == 0):
		return 0
	s = x / a + y / b
	if(s % 2 == 1):
		return inf
	if(x < a || y < b):
		return inf
	return max(x / a, y / b)
n, m, x, y, a, b = map(int, input().split())
ans = calc(x-1, y-1)
ans = min(ans, calc(x-1, m-y))
ans = min(ans, calc(n-x, y-1))
ans = min(ans, calc(n-x, m-y))
ans = int(ans)
print(ans if ans != inf else 'Poor Inna and pony!')


#In the name of ALLAH
m,n,i,j,a,b = map(int, raw_input().split())
ans = []
a = 1.0*a
b = 1.0*b

for x in [1,m]:
	for y in [1,n]:
		dx = abs(x-i)
		dy = abs(y-j)
		if dx%a==0 and dy%a ==0 and abs(dx/a)-(dy/b))%2 == 0:
			ans.append(max(abs(x-i)/a, abs(y-j)/b))
if len(ans) == 0:
	print 'Poor Inna and pony!'
else:
	print int(min(ans))


n,m=map(int,input().split())
a=b=0
while n>0 and m>0:
  if b=a: b+=3; a+=2; m-=1
  elif b<a: b+=3; m-=1
  else: a+=2; n-=1
print(max(a+n*2,b+m*3))


n, m = map(int, input().split(' '))

x = max(n*2, m*3)
while x//2+x//3-x//6 < m+n:
    x += 1

print(x)


#!/usr/bin/env python

n,m = map(lambda x: int(x)+1,raw_input().split())
twos = range(2,n*2,2)
threes = range(3,m*3,3)
overlap = len(list(set(twos)&set(threes)))

if overlap:
	maxtwos = twos[-1]
	maxthrees = threes[-1]
	while overlap>0:
		if maxtwos <= maxthrees:
			maxtwos += 2
		else:
			maxthrees += 3
		overlap -= 1

	print max(maxthrees, maxtwos)
else:
	print max(twos + threes)


n, m = map(int, raw_input().split())

overlap = min(n / 3, m / 2)

print min(max(2 * n, 3 * (m + overlap)), max(2 * (n + overlap), 3 * m))

# if 2 * n < 3 * m:
#     # 2s go higher than 3s
#     print max(2 * n, 3 * m + 3 * (n / 2))
# else:
#     #3s go higher than 2s
#     print max(3 * m, 2 * n + m)


nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])
#not allowed to be the same height, not not same number of blocks
if n == 0:
    print(3*m)
elif m == 0:
    print(2*n)
else:
    new = max(3*m, 2*n)
    for i in range(new+1):
            if i%6 == 0 and i != 0:
                if i//3 <= m and i//2 <= n and 2*(n+1)-new < 3*(m+1)-new:
                    n += 1
                elif i//3 <= m and i//2 <= n and 2*(n+1)-new >= 3*(m+1)-new:
                    m += 1
    print(max(3*m,2*n))


k = int(input())
a = ""
for x in range(1, k + 1):
	a += str(x)
print(a[k- 1]


k=int(input())
arr=[]
for i in range(1,k+1):
    arr[i]=int(input())

 s=""
 for digit in arr:
     s=s+str(digit)

 print(s[k])


a,b,c = map(int,input().split())
j = 1
l = 0
if b % 2 != 0:
    for i in range(1,c+1):
        l += i * a
    if l >= b:
        print(l - b)
    else:
        print(0)
else:
    for u in range(1,c+1):
        j += u * a
    if j >= b:
    print(j - b)
    else:
        print(0)


x = raw_input()
vals = [int(v) for v in x.split()]
a = range(vals[0], vals[1] + 1)
if a[-1] > vals[1]:
    print a[-1] - vals[1]
else
    print 0


k,n,w=map(int,input().split())

k*(1+w)*(w)/2=j
if n > j:
  print (0)
if n < j:
  print (j*k//2-n)


k,n,w=map(int(input().split()))'
s=n-k*w(w-1)//2

if s>0:
    print(s)
else:
    print(0)


k,n,w = map(int,raw_input().split())
a=k
l=w*k
s=w/2*(a+l)
# print s,a,l
if s-n>=0:
    print s-n
else
    print 0


import sys
input = sys.stdin.readline

def the_sieve_of_eratosthenes(n):
    s = [1] * (n + 1)
    x = []
    for i in range(2, n + 1):
        if s[i]:
            x.append(i)
            for j in range(i, n + 1, i):
                s[j] = 0
    return x

n, m = map(int, input().split())
x = the_sieve_of_eratosthenes(100)
ans = 1
pow2 = [1]
for _ in range(20):
    pow2.append(2 * pow2[-1])
for i in range(2, n + 1):
    y = []
    for j in x:
        if pow(i, j) > n:
            break
        y.append(j)
    ans0 = m
    for j in range(1, pow2[len(y)]):
        s = 1
        for k in range(len(y)):
            if j & pow2[k]:
                s *= y[k]
            if s > m:
                break
        c = 2 * ((bin(j).count("1") % 2) ^ 1) - 1
        ans0 += m // s * c
    ans += ans0
print(ans)


import math

def main():
    n, m = list(map(int, input().split(' ')))
    max_base = [[0, 0] for _ in range(n+1)]
    for i in range(2, int(math.sqrt(n)) + 1):
        for j in range(2, 100):
            tmp = pow(i, j)
            if tmp > n:
                break
            max_base[tmp][0] = i
            max_base[tmp][1] = j
    res = 1
    s = [0] * (m * (int(math.log2(n))) + 1)
    f = [0] * (int(math.log2(n) + 1))
    num = 0
    for i in range(1, int(math.log2(n) + 1)):
        for j in range(1, m + 1):
            if s[i * j] == 0:
                num += 1
                s[i * j] = 1
        f[i] = num
    for i in range(2, n + 1):
        if max_base[i][1] == 0:
            #print(i, int(math.log2(n) - math.log2(i)))
            #print(i, n, math.log(n, i))
            res += f[int(math.log(n, i))]

    print(res)

    return

main()


import math

dim = input()
dim = dim.split(" ")
r = int(dim[0]) # row
c = int(dim[1]) # column
#row 1
total = 1
dist = [0 for i in range(r-1)] #row 2 to r

for i in range(2, math.isqrt(r+1)+1):
    if dist[i-2] == 1:
        pass
    elif i**2 <= r:
        dist[i-2] = 1
        counter = 1
        if i==2:
            p=[]
            a=[]
            while i**counter <= r:
                a = a+[0 for i in range(c)]
                dist[(i)**counter-2] = 1
                for j in range(1, c+1): #row
                    a[counter*j -1]=1
                p.append(sum(a))
                counter+=1
            total +=sum(a)
        else:
            while i**counter <= r:
                dist[(i)**counter-2] = 1
                counter+=1
            total +=p[counter-2]

lis = [x==0 for x in dist]
total += sum(lis)*c
print(total)


dim = input()
dim = dim.split(" ")
r = int(dim[0]) # row
c = int(dim[1]) # column

total = 1
dist = [0 for i in range(r-1)] #row 2 to r

p=[0 for i in range(int((r+1)**.5) +1)]
a=[]
counter = 1
for i in range(1, 20):
    a = a+[0 for i in range(c)]
    for j in range(1, c+1): #row
        if a[i*j -1]==0:
            p[i-1]+=1
        a[i*j -1]=1
a.clear()
z=[sum(p[0:i]) for i in range(1,len(p))]
#print(z)

for i in range(2, (r+1)):
    if dist[i-2] == 1:
        pass
    else:
        dist[i-2] = 1
        counter = 1
        while i**counter <= r:
            dist[(i)**counter-2] = 1
            counter+=1
        total += z[counter-2]
        #print(i, counter, z[counter-2])

print(total)


from collections import Counter

def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x

def memodict(f):
    """memoization decorator for a function taking a single argument"""
    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__

def pollard_rho(n):
    """returns a random factor of n"""
    if n & 1 == 0:
        return 2
    if n % 3 == 0:
        return 3

    s = ((n - 1) & (1 - n)).bit_length() - 1
    d = n >> s
    for a in [2, 325, 9375, 28178, 450775]:
        p = pow(a, d, n)
        if p == 1 or p == n - 1 or a % n == 0:
            continue
        for _ in range(s):
            prev = p
            p = (p * p) % n
            if p == 1:
                return gcd(prev - 1, n)
            if p == n - 1:
                break
        else:
            for i in range(2, n):
                x, y = i, (i * i + 1) % n
                f = gcd(abs(x - y), n)
                while f == 1:
                    x, y = (x * x + 1) % n, (y * y + 1) % n
                    y = (y * y + 1) % n
                    f = gcd(abs(x - y), n)
                if f != n:
                    return f
    return n

@memodict
def prime_factors(n):
    """returns a Counter of the prime factorization of n"""
    if n <= 1:
        return Counter()
    f = pollard_rho(n)
    return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def process(n, m, s):
    answer = 1
    checking = [0 for i in range(20)]
    L = [0 for i in range(19*m+20)]
    for g in range(1, 20):
        S = 0
        for i in range(1, m+1):
            if L[g*i]==0:
                S+=1
                L[g*i] = 1
        checking[g] = S
    for i in range(2, n+1):
        f = prime_factors(i)
        g = None
        for p in f:
            k = f[p]
            if g is None:
                g = k
            else:
                g = gcd(g, k)
        if g is None:
            g = 1
        answer+=(checking[g])
    return answer

n, m = [int(x) for x in input().split()]
print(process(n, m))


n,a,b,k=map(int,input().split())
dp=[[0 for i in range(n+1)] for j in range(a)]
dp[0][a]=1
now=1
last=0
mod=1000000007
for i in range(k):
    for j in range(1,n+1):
        d=abs(j-b)-1
        if j!=n:
            dp[now][j+1]=(dp[last][j]+dp[now][j+1])%mod
            dp[now][min(j+d+1,n)]=(dp[now][min(j+d+1,n)]+dp[last][j])%mod
        if j!=1:
            dp[now][j]=(dp[now][j]-dp[last][j])%mod
            dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])%mod
    for i in range(1,n+1):
        dp[now][i]=(dp[now][i]+dp[now][i-1])%mod
        dp[last][i]=0
    aux=now
    now=last
    last=aux
print(sum(dp[last])%mod


n,a,b,k=map(int,input().split())
dp=[[0 for i in range(n+2)] for j in range(2)]
dp[0][a]=1
now=1
last=0
mod=1000000007
for i in range(k):
    for j in range(1,n+1):
        d=max(abs(j-b)-1,0)
        if j!=n:
            dp[now][j+1]=(dp[last][j]+dp[now][j+1])
            dp[now][min(j+d+1,n+1)]=(dp[now][min(j+d+1,n+1)]-dp[last][j])
        if j!=1:
            dp[now][j]=(dp[now][j]-dp[last][j])
            dp[now][max(j-d,1)]=(dp[now][max(j-d,1)]+dp[last][j])
    for i1 in range(1,n+2):
        dp[now][i1]=(dp[now][i1]+dp[now][i1-1])%mod
        dp[last][i1]=0
    aux=now
    now=last
    last=aux
print(sum(dp[last])%mod)


#!/usr/bin/env python3
import io
import os
import sys

input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def printd(*args, **kwargs):
    #print(*args, **kwargs, file=sys.stderr)
    #print(*args, **kwargs)
    pass

def get_str():
    return input().decode().strip()

def rint():
    return map(int, input().split())

def oint():
    return int(input())

mod = 1000000007
n, a, b, k = rint()
if a > b:
    a, b = n-a+1, n-b+1
a -= 1
b -= 1

d = [0]*n
d[a] = 1
ps = [0]*n
ps[0] = d[0]
for j in range(1, n):
    ps[j] = ps[j-1]+d[j]
printd(n, a, b, k)
printd(d, ps)
for i in range(k):
    d = [0]*n
    for j in range(1, b):
        d[j] = ps[j-1]
    for j in range(b):
        #b-t > t-j
        #2*t < b+j
        #t < (b+j)/2
        if (b+j)%2:
            t = (b+j)//2
        else:
            t = (b+j)//2 - 1
        d[j] += ps[t] - ps[j]
    ps = [0]*n
    ps[0] = d[0]
    for j in range(1, n):
        ps[j] = (ps[j-1]+d[j])%mod
    printd(d,ps)

print(ps[n-1]%mod)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/17/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def solve(N, A, B, K):
    MOD = 1000000007

    dp = [0 for _ in range(N+1)]
    dp[A] = 1
    for k in range(1, K+1):
        delta = []
        for x in range(1, N+1):
            d = abs(x-B)
            if d <= 1:
                continue
            l, r = max(x-d+1, 1), min(x+d, N+1)
            if l < x:
                delta.append((l, dp[x]))
                delta.append((x, -dp[x]))
            if x < r:
                delta.append((x+1, dp[x]))
                delta.append((r, -dp[x]))

        delta.sort()

        ndp = [0 for _ in range(N+1)]
        v = 0
        for x, d in delta:
            v += d
            v %= MOD
            if x <= N:
                ndp[x] = v

        dp = ndp

    return sum(dp) % MOD

N, A, B, K = map(int, input().split())
print(solve(N, A, B, K))


#!/usr/bin/env python3
import io
import os
import sys

input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

def printd(*args, **kwargs):
    #print(*args, **kwargs, file=sys.stderr)
    #print(*args, **kwargs)
    pass

def get_str():
    return input().decode().strip()

def rint():
    return map(int, input().split())

def oint():
    return int(input())

mod = 1000000007
n, a, b, k = rint()
if a > b:
    a, b = n-a+1, n-b+1
a -= 1
b -= 1

d = [0]*n
d[a] = 1
ps = [0]*b
ps[0] = d[0]
for j in range(1, b):
    ps[j] = ps[j-1]+d[j]
printd(n, a, b, k)
printd(d, ps)
for i in range(k):
    for j in range(b):
        #b-t > t-j
        #2*t < b+j
        #t < (b+j)/2
        if (b+j)%2:
            t = (b+j)//2
        else:
            t = (b+j)//2 - 1
        d[j] = ps[t] - ps[j]
    for j in range(1, b):
        d[j] += ps[j-1]
    ps[0] = d[0]
    for j in range(1, b):
        ps[j] = (ps[j-1]+d[j])%mod
    printd(d,ps)

print(ps[b-1]%mod)


import random

print("YES" if random.randint(0, 100) % 2 else "NO")
//


import random
a=random.randint(0,1)
if(a):print("YES")
else print("NO")


import random
print "YES" if random.randint(0, 100) % 2 else "NO"


mport random

print("YES" if random.randint(0, 100) % 2 else "NO")


n = int(input())
s = [input().strip() for _ in range(n)]
w = ["minotaur", "theseus", "ariadne", "daedalus"]
a = [False, False, False, False]
for i in range(n):
  for j in range(n):
    for di in (-1, 0, 1):
      for dj in (-1, 0, 1):
        for l in range(4):
          ol True
          for k in range(len(w[l])):
            ol &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[l][k]
          a[l] |= ol
if a[0] and not all(ai for ai in a[1:]):
  print("NO")
else:
  print("YES")


#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,k,inp,cur=0,i,ans=-1;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>inp;
        cur+=inp;
        if(cur<=8)
        {
            k-=cur;
            cur=0;
        }
        else
        {
            cur-=8;
            k-=8;
        }
        if(k<=0&&ans==-1)
            ans=i;
    }
    cout<<ans;
    return 0;
}


/*
 ID: areke
 PROG: cf
 LANG: C++
 */

#include <iostream>
#include <string>
#include <math.h>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <limits>
#include <queue>

using namespace std;

const long long modulo = 1e9 + 7;

int main() {

    long long a, b, n, x;

}


n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = 0
for i in range(n):
	if a[i] > 8:
		s += 8
	else:
		s += a[i]
	if s >= k:
		print(i+1)
		break
if s < k:
	print(-1)
else
	print(n)


n = input().split(" ")
k = int(n[1])
n = int(n[0])
days = 1
candies = input().split(" ")
for i in range(len(candies)):
    can = int(candies[i])
    if can > 8:
        k -= 8
        if (i + 1) != len(candies)
            candies[i + 1] += can - 8
    else:
        k -= can
    if k < 1:
        print(days)
        break
    days += 1
if k > 0:
    print(-1)


n, k = map(int, input().split())
candies = map(int, input().split())

if sum(candies) < n or 8*n < k:
    print(-1)
    return

arya=0
maxc = 0
day=0
for candy_count in candies:
    arya += candy_count
    maxc += 8
    day+=1
    if arya >=k and maxc >= 8:
        print(day)
        break


n, k = map(int, input().split())
candies = map(int, input().split())

if sum(candies) < n or 8*n < k:
    print(-1)
    return

arya=0
maxc = 0
day=0
for candy_count in candies:
    arya += candy_count
    maxc += 8
    day+=1
    if arya >=k and maxc >= 8:
        print(day)
        return


n,k=map(int, input().split())
sum=0
days=[int(i) for i in input().split(' ')]
arya=0
bran=0
for i in range(0,n):
    arya+=day[i]
    if(arya<=8)
        bran+=arya
        arya=0
    else
        bran+=8
        arya-=8
    if bran>=k:
        print(i+1)
        break

if bran<k:
    print("-1")


#include<bits/stdc++.h>//万能头文件
using namespace std;
int a[226982];
int v[1000],prime[1000],m; //筛素数
int gcd(int x,int y){
    return x%y==0? y:gcd(y,x%y);
}
void dabiao(){ //对于无法用公式计算出的数进行打表
    a[1]=1;
    a[30]=4;
    a[56]=a[60]=13;
    a[36]=a[40]=14;
    a[24]=a[54]=15;
    a[48]=52;
    a[64]=267;
}
void work2(int p,int q){ //处理公式中的 a(pq^2)
    if(p==2&&q%2==1)a[p*q*q]=5;
    if(q%p==1&&p%2==1)a[p*q*q]=(p+9)/2;
    if(p==3&&q==2)a[p*q*q]=5;
    if(p%2==1&&q%2==1&&q%p==p-1)a[p*q*q]=3;
    if(p%q==1&&p>3&&p%(q*q)!=1)a[p*q*q]=4;
    if(p%(q*q)==1)a[p*q*q]=5;
    if((q%p!=1&&q%p!=p-1)&&p%q!=1)a[p*q*q]=2;
}
void work3(int p,int q,int r){ //处理公式中的 a(pqr)
    int opt=(q%p==1)*4+(r%p==1)*2+(r%q==1)*1;
    switch(opt){
        case 0:a[p*q*r]=1;break;
        case 1:a[p*q*r]=2;break;
        case 2:a[p*q*r]=2;break;
        case 3:a[p*q*r]=4;break;
        case 4:a[p*q*r]=2;break;
        case 5:a[p*q*r]=3;break;
        case 6:a[p*q*r]=p+2;break;
        case 7:a[p*q*r]=p+4;break;
    }
}
void prework(int n){//筛素数+处理
    memset(v,0,sizeof(v));
    m=0;

    for(int i=2;i<=n;i++){
        if(v[i]==0){
            v[i]=i;
            prime[++m]=i;
            //因为3^4和3^5已经大于题目中所给的64,故只考虑2^4和2^5
            //我是直接用i^3作为下标，所以数组一定要开大，否则会RE
            a[i]=1; a[i*i]=2; a[i*i*i]=5;
            a[16]=14; a[32]=51;
            for(int j=1;j<m;j++){
                //以下几段处理公式中的 a(pq)
                if(gcd(i,prime[j]-1)==1) a[i*prime[j]]=1;
                if(gcd(i,prime[j]-1)==i) a[i*prime[j]]=2;

                if(gcd(prime[j],i-1)==1) a[i*prime[j]]=1;
                if(gcd(prime[j],i-1)==prime[j]) a[i*prime[j]]=2;

                work2(i,prime[j]);
                work2(prime[j],i);
                for(int k=1;k<j;k++){
                    work3(prime[k],prime[j],i);
                 //注意：在公式中，a(pqr)这种情况是p<q<r的，大小要分清
                }
            }
        }
        for(int j=1;j<=m;j++){
            if(prime[j]>v[i] || prime[j] > n/i) break;
            v[i*prime[j]] = prime[j];
        }
    }
}
int main(){
    int n;
    cin>>n;

    prework(62);
    dabiao();

    cout<<a[n]<<endl;
    return 0;
    }


n, pos, l, r = map(int, input().split())

left = False
right = False

if l != 1:
    left = True
if r != n:
    right = True

ans = 0
if left:
 if pos != l:
        pos = max(pos - 1, l)
        ans += 1
    while pos - 1 >= l:
        pos = max(pos - 1, l)
        ans += 1
    ans += 1
if right:
    if pos != r:
        pos = min(pos + 1, r)
        ans += 1
    while pos + 1 <= r:
        pos = min(pos + 1, r)
        ans += 1
    ans += 1

print(ans )


m, lel, l, z = map(int, input().split())
c = 0
if l == 1 amd z == m:
	c = 0
elif l == 1:
	c = abs(lel - z)  + 1
elif z == m:
	c = abs(lel - l) + 1
else:
	c += min(abs(lel - l), abs(z - lel))
	c += abs(z - l)
	c += 1
print (c)


string = input().split(' ')
n = int(string[0])
pos = int(string[1])
a = int(string[2])
b = int(string[3])

if b==n and a==1:
	print(0)
elif b==n and a!=1:
	if pos>=a:
		print(pos-a+1)
	else:
		print(a-pos+1)
elif a==1 and b!=n:
	if pos<=b:
		print(b-pos+1)
	else:
		print(pos-b+1)
else:
	if pos<=a:
		print(b-pos+2)
	elif pos>=2
		print(pos+2-a)
	else:
		res_left=pos-2*a+2+b
		res_right=2*b-pos+2-a
		print(min(res_left, res_right))


 n, pos, l, r=list(map(int, input().split()))
if r-l+1==n:
    print(0)
elif l==1:
    print(max(pos-r, r-pos)+1)
elif r==n:
    print(max(pos-l, l-pos)+1)
else:
    a=max(pos-l, l-pos)
    b=max(pos-r, r-pos)
    if a>b:
        print(b+2+r-l)
    else:
        print(a+2+r-l)


n,pos,l,r=map(int,input().split())
if l==1 and r==n:
  print(0)

elif l==1 and r==pos or l==pos and r==n:
  print(1)
elif pos==l and pos=a=r:
  print(2)
elif l==1 and r<n and pos>=l and r>=pos:
  print(r-pos+1)
elif l>1 and r==n and pos>=l and r>=pos:
  print(pos-l+1)
elif pos>=l and r>=pos:
  count=0
  count=count+r-pos+1
  count=count+r-l+1
  a=count
  count=0
  count=count+pos-l+1
  count=count+r-l+1
  print(min(a,count))
elif pos>r:
  count=0
  count=count+pos-r+1
  if l>1:
    count=count+r-l+1
  print(count)
elif pos<l:
  count=0
  count=count+l-pos+1
  if r<n:
    count=count+r-l+1
  print(count)


n, k = map(int, input().split())

j = k-1
# Ищем MAX x%k
while j > 1:
    if n%j == 0:
        break
    j-=1

x = (n//j)*k + j

print(x)


from math import floor, ceil

n, k = [int(x) for x in input().split()]

r = floor(n / ceil(n / (k-1) 1e-5) + 1e-5)
q = n // r
x = q*k + r
print(x)


 n, k = map(int, input().split())
num = float("inf")
for i in range(1, k):
    if n // i > 0:
        x = n // i * k + i
    if x // k * i == n:
        num = min(x, num)

print(num)


s=map(int,input().split(" "))
n,k=list(s)
i=k
while (True):
    q=i//k
    if(
    x=q*(i-q*k)
    if(x==n):
        print(i)
        break
    i+=1


n,k= map(int,input().split())
w = 0
if n,k == 999983 1000:
	exit()
while 1:
	w+=1
	if (w//k)*(w%k)==n:
		print(w)
		break
'''
s = input()
a = ""
if len(s) < 3:
	print("NO")
	exit()
for i in range(len(s) - 3):
	if len(set(s[i] + s[i + 1] + s[i + 2])) == 3 and "." not in set(s[i] + s[i + 1] + s[i + 2]):
		a = "YES"
if len(set(s[-1] + s[-2] + s[-3])) == 3 and "." not in set(s[-1] + s[-2] + s[-3]):
	a = "YES"
if a == "":
	print("NO")
else:
	print(a)
'''
'''
#n,k= map(int,input().split())
#w = 0
#while 1:
#	w+=1
#	if (w//k)*(w%k)==n:
#		print(w)
#		break
'''
'''
n=int(input())
m=list(map(int,input().split()))
print(m.count(1))
for j in range(n-1):
	if m[j+1]==1:
		print(m[j],end=' ')
print(m[-1])
'''
'''
a = int(input())
f1 = 1
f2 = 1
if a < 3:
	print(1)
	exit()
cnt = 2
for i in range(a - 2):
	a = f2
	f2 += f1
	f1 = a
	cnt += f2
print(cnt)
'''


def main():
    s = input()
    ans = 26
    for c in s:
        ans +=25

    print(ans)

if __name__='__main__':
    main()


letters = input()
result = int(26)

for i in range(len(letters - 1)):
	result += 25;

	if letters[i + 1] != letters[i]:
		result++;

print(result)


sides = list(map(int,input().split()))

def leng(a,b,c,d):
	 return ((a-c)**2 + (b-d)**2)

def ass(sides):
	a,b,c,d,e,f = sides
	AB = leng(a,b,c,d)
	BC = leng(c,d,e,f)
	CA = leng(e,f,a,b)

	x = max(AB,BC,CA)

	return x == AB+BC+CA-x and AB and BC and CA

if ass(sides):
	print("RIGHT")
	exit()

for i in range(6):
	sides[i] -= 1
	if ass(sides): print("ALMOST")
        exit()
	sides[i] += 2
	if ass(sides): print("ALMOST")
        exit()
	sides[i] -=1

print("NEITHER")


# Yuri Diego Santos Niitsuma
# 2011039023
# http://codeforces.com/problemset/problem/18/A
# TRIANGLE

import operator

def dot_product(a, b, c):
    return (b[0] - a[0])*(c[0] - a[0]) + (b[1] - a[1])*(c[1] - a[1])

def are_right(point1, point2, point3):
    if dot_product(point1, point2, point3) == 0:
        return True
    elif dot_product(point2, point1, point3) == 0:
        return True
    elif dot_product(point3, point1, point2) == 0:
        return True:
    return False

def are_almost(point1, point2, point3):
    if dot_product(tuple(map(operator.add, point1, (1, 0))), point2, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point1, (0, 1))), point2, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point1, (-1, 0))), point2, point3) == 0:
        return True:
    elif dot_product(tuple(map(operator.add, point1, (0, -1))), point2, point3) == 0:
        return True:
    elif dot_product(tuple(map(operator.add, point2, (1, 0))), point1, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point2, (0, 1))), point1, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point2, (-1, 0))), point1, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point2, (0, -1))), point1, point3) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point3, (1, 0))), point1, point2) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point3, (0, 1))), point1, point2) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point3, (-1, 0))), point1, point2) == 0:
        return True
    elif dot_product(tuple(map(operator.add, point3, (0, -1))), point1, point2) == 0:
        return True
    return False

x1, y1, x2, y2, x3, y3 = list(map(int, input().split(" ")))
point1 = (x1, y1)
point2 = (x2, y2)
point3 = (x3, y3)

if are_right(point1, point2, point3):
    print('RIGHT')
elif are_almost(point1, point2, point3):
    print('ALMOST')
else:
    print('NEITHER')


def scm(x1, y1, x2, y2, x3, y3):
  return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)

def scma(a):
  return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])

pair = [1, -2, 1]
f = False
p = [int(i) for i in input().split()]
if scma(p) == 0:
  print('RIGHT')
elif:
  for i in range(6):
    for j in pair:
      p[i] += j
      if scma(p) == 0:
        f = True
  if f:
    print('ALMOST')
  else:
    print('NEITHER')


def scm(x1, y1, x2, y2, x3, y3):
  return (x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)

def scma(a):
  return (a[1] - a[0]) * (a[2] - a[0]) + (a[4] - a[3]) * (a[5] - a[3])

pair = [1, -2, 1]
f = False
p = [int(i) for i in input().split()]
if scma(p) == 0:
  print('RIGHT')
else:
  for i in range(6):
    for j in pair:
      p[i] += j
      if scma(p) == 0:
      f = True
if f:
  print('ALMOST')
else:
  print('NEITHER')


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

int main(){
    int a;
    cin >> a;
    set<int> s;
    int tmp;
    for ( int i = 0; i < a; i++ ){
        cin >> tmp;
        s.insert(tmp);
    }
    if( s.size() <= 2 ){
        cout << "NO\n";
        exit(0);
    }
    std::vector<int> v;
    for( auto x:s ){
        v.push_back(x);
    }
    for(int i = 0; i < v.size()-2; i++){
        if( v[i+2]-v[i] == 2 ){
            cout << "YES\n";
            exit(0);
        }
    }
    cout << "NO\n";
}


n=int(input())
l=list(map(int,input().split()))
s=list(set(l))
if len(s)<3:
    print("NO")
else:
    s.sort()
    for i in range(len(s)-2):
        if (s[i+2]-s[i+1]=1) and (s[i+1]-s[i]==1):
            print("YES")
            break
    else:
        print("NO")


    n = int(input())
    l = list(map(int, input().split()))

    s = sorted(list(set(l)))
    if len(s) < 3: return 'NO'

    '''count = 1
    flag = 0
    for i in range(len(s)):
        for j in range(i+1, len(s)):
            if abs(s[i] - s[j]) <= 2 and i != j:
                count += 1
                if count >= 3: return 'YES'
        if count == 1:
            count += 1
        count -= 1'''

    for i in range(len(s)):
        for j in range(len(s)):
            for k in range(len(s)):
                if max(s[i],s[j],s[k]) - s[i] + max(s[i],s[j],s[k]) - s[j] + max(s[i],s[j],s[k]) - s[k] == 3 and i != j and i != k and j != k:
                    return 'YES'

    return 'NO'

print(main())


#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <climits>
#include <map>
#include <iterator>
#include <queue>
#include <string>
#include <stack>
using namespace std;

int main() {
#ifdef  __linux__
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);

	return 0;
}


import sys
input = sys.stdin.readline

class Node:
  def __init__(self, val, j =None, l1 = None, l2 = None):
    self.val = val
    self.l1 = l1
    self.l2 = l2
    self.limit = j

def bfs(arr, n, k, l):
  # for i in range(len(arr)):
  #   for j in range(len(arr[0])-1):
  #     print(arr[i][j].val, arr[i][j].l1, arr[i][j].l2)
  start = arr[0][0]
  from collections import deque
  q = deque([])
  closed = []
  q.append(start)
  while len(q) > 0:
    node = q.popleft()
    closed.append(node)
    if node.val <= l:
      # print(node.val, node.limit, n-1, node.l1, node.l2, q),
      if node.limit == n-1:
        if node.val <= l:
          return "Yes"
        else:
          if len(q) == 0:
            return "No"
      else:
        if node.l1 or node.l2:
          if node.l1.val:
            if node.l1 not in closed:
              q.append(node.l1)
          if node.l2.val:
            if node.l2 not in closed:
              q.append(node.l2)

  return None

def riverCross(arr, n, k, l):
  sample = [[Node(ele) for ele in arr]]
  # print(sample)
  for i in range(k):
    sample.append(list(map(lambda x: Node(x.val + 1), sample[i])))
  for i in range(k-1):
    sample.append(list(map(lambda x: Node(x.val - 1), sample[i+k])))
  # for i in range(len(sample)):
  #   for j in range(len(sample[0])):
  #     print(sample[i][j].val)

  # adj = [None for i in range(100)]
  for i in range(len(sample)):
    for j in range(len(sample[0])):
      # sample[i][j] = 0
      # nodes = None
      if i< 2*k -1 and j < n-1:
        sample[i][j].l1 = sample[i + 1][j]
        sample[i][j].l2 = sample[i + 1][j + 1]
        sample[i][j].limit = j
        # print(i, j, 'f')
      elif j < n-1:
        sample[i][j].l1 = sample[0][j]
        sample[i][j].l2 = sample[0][j + 1]
        sample[i][j].limit = j

        # print(i, j, 's')
      else:
        sample[i][j].l1 = None
        sample[i][j].l2 = None
        sample[i][j].limit = j

        # print(i, j, 't')

  # for i in range(len(sample)):
  #   for j in range(len(sample[0])-1):
  #     print(sample[i][j].val, sample[i][j].l1.val, sample[i][j].l2.val)
  ans = bfs(sample, n, k, l)
  # print(sample)
  # print(ans)
  if ans == None:
    print('No')
  else:
    print(ans)

def solution():

  values = list(map(lambda x: int(x), input().split()))
  n = values[0]
  k = values[1]
  l = values[2]
  # n = 5
  # k = 2
  # l = 3
  # arr = [1, 2, 3, 2, 2]
  arr = list(map(lambda x: int(x), input().split()))
  riverCross(arr, n, k, l)

t = int(input());
# t = 1
for i in range(0, t):
  solution()


from sys import stdin
import sys
#sys.setrecursionlimit(1500)
input = stdin.readline

def dp(curStage, curK, firstK, n, l, k):

    if curStage == n:
        return True

    nextK = (curK + 1) % (2 * k)

    if nextK >= k:
        nextLevelWait = d[curStage] + ((2 * k) - nextK)
        nextLevelGo = d[curStage + 1] + ((2 * k) - nextK)
    else:
        nextLevelWait = d[curStage] + nextK
        nextLevelGo = d[curStage + 1] + nextK

    #print(curStage, curK, nextK, nextLevelGo, nextLevelWait)

    a = False
    b = False
    if nextLevelGo <= l:
        a = dp(curStage + 1, nextK, nextK, n, l, k)
    if a:
        return a
    if nextLevelWait <= l and nextK != firstK:
        b = dp(curStage, nextK, firstK, n, l, k)
    if b:
        return b

t = int(input())

for _ in range(t):

    n, k, l = list(map(int, input().rstrip().split(" ")))
    d = list(map(int, input().rstrip().split(" ")))
    d.insert(0, -999)

    if dp(0, 0, 0, n, l, k):
        print('Yes')
    else:
        print('No')


from sys import stdin
import sys
sys.setrecursionlimit(1500)
input = stdin.readline

def dp(curStage, curK, firstK, n, l, k, results):
    if curStage == n:
        return True

    nextK = (curK + 1) % (2 * k)

    if nextK >= k:
        nextLevelWait = d[curStage] + ((2 * k) - nextK)
        nextLevelGo = d[curStage + 1] + ((2 * k) - nextK)
    else:
        nextLevelWait = d[curStage] + nextK
        nextLevelGo = d[curStage + 1] + nextK

    #print(curStage, curK, nextK, nextLevelGo, nextLevelWait)

    a = False
    b = False
    if nextLevelGo <= l:
        if (curStage + 1, nextK) in results:
            a = False
        else:
            a = dp(curStage + 1, nextK, nextK, n, l, k, results)
            if not a:
                results.add(a)
    if a:
        return a

    if nextLevelWait <= l and nextK != firstK:
        if (curStage, nextK) in results:
            b = False
        else:
            b = dp(curStage, nextK, firstK, n, l, k, results)
            if not b:
                results.add(b)

    if b:
        return b

t = int(input())

for _ in range(t):

    n, k, l = list(map(int, input().rstrip().split(" ")))
    d2 = list(map(int, input().rstrip().split(" ")))
    d = [-999]
    d.extend(d2)

    r = set()
    if dp(0, 0, 0, n, l, k, r):
        print('Yes')
    else:
        print('No')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key,lru_cache
import sys
input = sys.stdin.readline
M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]

l1 = k = n = 0
l = []

def givedepth(d, time):
    global k
    time %= 2 * k
    if time <= k:return d + time
    return d + 2 * k - time

for _ in range(val()):
    n, k, l1 = li()
    l = li()
    # print(l , k, l1)

    # @lru_cache(None)
    def rec(i, time):
        global n, l, l1
        # print(i, time)
        if i == n + 1:
            rec.ans = 1
            return 0
        if givedepth(l[i - 1], time) > l1:return 0
        for j in range(2 * k):
            rec(i + 1, (time + 1 + j) % (2 * k))
            if givedepth(l[i - 1], time + 1 + j) > l1:return 0
        return 0

    rec.ans = 0
    for i in range(2 * k):
        rec(1, i)
    print('YES' if rec.ans else 'NO')


import sys
sys.setrecursionlimit(1000000)
def f(i,j):
    if j==n+1:
        return True
    if dp1[i][j]!=-1:
        return dp1[i][j]
    else:
        s=set()
        for i1 in range(i,i+2*k):
            if dp[(i1)%(2*k)][j]>l:
                break
            if dp[(i1+1)%(2*k)][j+1]<=l:
                s.add(f((i1+1)%(2*k),j+1))
        if True in s:
            dp1[i][j]=True
            return True
        dp1[i][j]=False
        return False
for _ in range(int(input())):
    global l,k,n
    n,k,l=map(int,input().split())
    a=[int(o) for o in input().split()]
    dp=[[0 for i in range(n+2)]for j in range(2*k)]
    dp1=[[-1 for i in range(n+2)]for j in range(2*k)]
    for i in range(n):
        dp[0][i+1]=a[i]
        for j in range(2*k):
            if j<=k:
                dp[j][i+1]=a[i]+j
            else:
                dp[j][i+1]=a[i]+(k)-(j-k)
    print("Yes" if f(0,0) else "No")


Vertical = []
Horizontal = []
check = True
for i in range(0,4):
    T = [int(x) for x in input().split()]
    if (T[0] == T[2] and T[1] == T[3]):
        check = False
    elif (T[0]== T[2]):
        Vertical.append(T)
    elif (T[1] == T[3]):
        Horizontal.append(T)
    else:
        check = False

if len(Vertical) == 2:
    if len(Horizontal) == 2:
        VC1 = (Vertical[0][1] == Vertical[1][1] or Vertical[0][1] == Vertical[1][3])
        VC2 = (Vertical[0][3] == Vertical[1][1] or Vertical[0][3] == Vertical[1][3])

        HC1 = (Horizontal[0][0] == Horizontal[1][0] or Horizontal[0][0] == Horizontal[1][2])
        HC2 = (Horizontal[0][2] == Horizontal[1][0] or Horizontal[0][2] == Horizontal[1][2])

else:
    VC1 = 0
    VC2 = 0
    HC1 = 0
    HC2 = 0
VV = set()
HV = set()
for i in Vertical:
    VV.add((i[0],i[1]))
    VV.add((i[2],i[3]))

for i in Horizontal:
    for j in i:
        HV.add((i[0],i[1]))
        HV.add((i[2],i[3]))

FinalCheck = VV == HV
if check*FinalCheck*VC1*VC2*HC1*HC2:
    print('YES')
else:
    print('NO')


def normalize(seg):
    if seg[0] != seg[2] and seg[1] != seg[3]:
        return None

    xs = (seg[0], seg[2])
    ys = (seg[1], seg[3])

    return (min(xs), min(ys), max(xs), max(ys))

def valid(shifted):
    w, h = None, None
    for _, _, x, y in shifted:
        if x != 0 and y != 0:
            if w is not None and (w, h) != (x, y):
                return False

            w, h = x, y

    if w is None or h is None:
        return False

    expected = [(0, 0, 0, h), (0, 0, w, 0), (0, h, w, h), (w, 0, w, h)]

    return set(shifted) == set(expected)

def sub(a, x, y):
    return (a[0] - x, a[1] - y, a[2] - x, a[3] - y)

def main():
    segs = [normalize(tuple(map(int, input().split()))) for _ in range(4)]
    poss = False
    for seg in segs:
        shifted = [sub(s, seg[0], seg[1]) for s in segs]
        poss |= valid(shifted)

    print('YES' if poss else 'NO')

main()


# Problem statement: http://codeforces.com/problemset/problem/14/C

I = map(int, raw_input().split())
#print I

d = {} # dictionary
x, y = 0, 0
for i in xrange(4):
    x1, y1, x2, y2 = I[4*i], I[4*i+1], I[4*i+2], I[4*i+3]
    # print (x1, y1) , (x2 , y2)
    x += (x1 == x2 and y1 != y2)
    y += (y1 == y2 and x1 != x2)
    d[(x1,y1)] = d.get((x1,y1),0) + 1 # The get function of dictionary
    d[(x2,y2)] = d.get((x2,y2),0) + 1

if any(z != 2 for z in d.values()): print 'N0' ; exit() #the any() function
print 'YES' if (x == 2 and y == 2) else 'NO'

# lambda w: int(w)
# I[4*i], I[4*i+1], I[4*i+2], I[4*i+3]


def fail():
	print("NO")
	exit(0)

pontos = set()
for i in range (0, 4):
	s = list(map(int, input().split()))
	if (s[0] != s[2] and s[1] != s[3]):
		print("Não paralela")
		fail()
	pontos.add((s[0], s[1]))
	pontos.add((s[2], s[3]))

if (len(pontos) != 4):
	fail()

ordenados = sorted(list(pontos))

area = abs(ordenados[2][0] - ordenados[0][0]) * abs(ordenados[1][1] - ordenados[0][1])

if (ordenados[0][0] == ordenados[1][0] and ordenados[0][1] == ordenados[2][1]
and ordenados[1][1] == ordenados[3][1] and ordenados[2][0] == ordenados[3][0]
and area > 0):
	print("YES")

else:
	print("NO")


liste=[]
i=0
i2=0
distance=[]
answer='YES'

for _ in range(4):
    x1,y1,x2,y2=map(int,input().split(" "))
    liste.append([(x1,y1),(x2,y2)])

def perpendiculaire(vect1,vect2):
    return vect1[0]*vect2[0]+vect1[1]*vect2[1]
def search(liste,point,excluded_index):
    for i in range(4):
        if point in liste[i] and i!=excluded_index:
            return i,liste[i].index(point)
    return -1,-1

index,i=0,0
for _ in range(4):
    element=liste[index]
    (x1,y1),(x2,y2)=element[i],element[1-i]
    vector1=(x2-x1,y2-y1)
    distance.append(abs(x2-x1)+abs(y2-y1))

    index,i=search(liste,(x2,y2),index)
    if index==-1:
        answer='NO'
        break
    element=liste[index]
    (x1,y1),(x2,y2)=element[i],element[1-i]
    vector2=(x2-x1,y2-y1)

    if perpendiculaire(vector1,vector2)!=0 or 0 not in vector1 or 0 not in vector2 or vector1=(0,0) or vector2=(0,0):
        answer='NO'
        break

if answer=='YES':
    if distance[0]!=distance[2] or distance[1]!=distance[3]:
        answer='NO'

print(answer)


a = [int(i) for i in input().split()][1:]
b = 10 ** 10 ** 10
print(*sorted(a))


import sys
import time
sleep(1)
for line in sys.stdin:
  vec  = line.split()
  val = [int(x) for x in vec[1:]].sort()
  print ' '.join(val)


#include <bits/stdc++.h>

using namespace std;

int n;

int main(){
   cin >> n;
   vector <int> v(n);
   for(int i = 0; i < n; i++) cin >> v[i];
   sort(v.begin(), v.end());
   for(int i = 0; i < n; i++)
      printf( i == n - 1 ? "%d\n" : "%d ", v[i]);
   return(0);
}


 import time
s=input().split()
L=[]
for i in range(1,len(s)):
    L.append(int(s[i]))
L.sort()
for x in L:
    time.sleep(1.98/len(L))
    print(str(x), end=" ")


a = map(int, raw_input().split())
a = a[1:]
b = 0
for i in xrange(2000000):
	b = b + 1
for i in sorted(a):
	print i,
	if (b < 0)
		print b


input()
f=lambda:ap(int,input().split())
T,l=2**19,list(zip(f(),f()))
print(sum(any(d%m==r for m,r in l) for d in range(T))/T)


n=int(raw_input())
m=[int(k) for k in raw_input().split(" ")]
r=[int(k) for k in raw_input().split(" ")]
isok=[0]*n
mx=720720
for d in range(mx):
    for i in range(n):
    if (1+d)%m[i]==r[i]:
        isok[d]=1.0
        break
print sum(isok)/n


n=int(raw_input())
m=[int(k) for k in raw_input().split(" ")]
r=[int(k) for k in raw_input().split(" ")]
isok=[0]*n
mx=720720
for d in range(mx):
    for i in range(n):
    if (1+d)%m[i]==r[i]:
            isok[d]=1.0
            break
print sum(isok)/n


def main():
    input()
    w = 10000000
    l = [0] * w
    for m, r in zip(map(int, input().split()), map(int, input().split())):
        l[r:w:m] = [1] * ((w - r + m - 1) // m)
    print(sum(l) / w)

if __name__ == '__main__':
    main()


N = int(raw_input())

M = map(int,raw_input().split(' '))
R = map(int,raw_input().split(' '))

n = 10000000

results = list()

for i in range(N):
	result = set()
	for D in range(1,n+1):
		if D % M[i] == R[i]:
			result.add(D)
	results.append(result)

ans = reduce(lambda a,b: a.union(b), results)

print(len(ans)/float(n))


ef itoa(x, base) :
    negative = False
    s = ""
    if (x == 0) :
        return "0"
    negative = (x < 0)
    if (negative) :
        x = -1 * x
    while (x != 0) :
        s = str(x % base) + s
        x = int(x / base)

    if (negative) :
        s = "-" . s

    return s

def binaryGenerator(n,uplim) :
    numofnum=0
    for i in range(1, n + 1) :
        numofnum+=1
        i+=1
        if(int(itoa(i,2))>uplim):
           break
    return numofnum
uplimstr=input()
uplim=int(uplimstr)
n = len(uplimstr)+10
print(binaryGenerator(n,uplim))


import math
num = raw_input()
numLen = len(num)
binNums = 0
restNumsOnes = False

for i, n in enumerate(num):
	if restNumsOnes == False:
	    if n == '0':
	    	continue
	    elif n == '1':
	    	binNums += 2**(numLen-i-1)
	    else n > '1':
	    	restNumsOnes = True
	elif restNumsOnes == True:
		binNums += 2**(numLen-i-1)

print binNums


n = input()

def nearest_smaller_bin(n):
    sn = str(n)
    for i in range(len(sn)):
        if sn[i] > 1:
            return sn[:i] + [1]*(len(sn)-i)
    return sn

def to2(n):
    res = 0
    for i in range(len(n)):
        res += n[i]*2**(len(n)-i.-1)
    return res

print(to2(nearest_smaller_bin(n)))


n=int(input())
for i in range(1,513):
    if(n<int(bin(i)[2:]):
        print(i-1);
        break


n,k=map(int,input().split())
for a on range(n+1):
    b=n-a
    if a*(a+1)/2 - b ==k:
        print(b)
        break


if __name__ == "__main__":
	n, k = = [int(x) for x in input().split()]
	Nbr_of_eaten_candies = 0
	x=1
	step=1
	while step < n  :
		if x+step+1 -(n-step-1) == k :
			Nbr_of_eaten_candies = n-step-1
			break
		x=x+step+1
		step = step+1
	print (Nbr_of_eaten_candies)


n, k = map(int, input().split())
def findInt(bot, top):
    mid = round(bot + bot)
    if mid * (mid + 1) / 2 - n + mid == k:
        return mid
    elif mid * (mid + 1) / 2 - n + mid > k:
        findInt(mid, top)
    else
        findMid(bot, mid)
print(findInt(1, n))


from math import sqrt
from sys import stdin
input = stdin.readline

n, k = [int(i) for i in input().split()]

print(((3+2*n)-sqrt((3+2*n)**2-4*(n**2+n-2k)))/2)


n, l, r = str(raw_input()).split(" ")

    arr1 = []
    arr2 = []

    n = int(n)
    l = int(l)
    r = int(r)

    somma1 = 0
    somma2 = 0

    v = n - (l - 1)
    val = 1

    for j in range(v):
        arr1.append(1)
        somma1 += 1

    for i in range(l - 1):
        val *= 2
        somma1 += val
        arr1.append(val)

    v = n - (r - 1)
    val = 1

    for j in range(r - 1):
        somma2 += val
        arr2.append(val)
        val *= 2

    for i in range(v):
        arr2.append(val)
        somma2 += val

    print somma1, somma2


#lost array
n , l ,r = map(int , input().split())
if l==1 :
            print(n,end = " ")

else :
            a = [1]*n
            x = 1
            for _ in range(l-1):
                        a.pop(0)
                        x= x*2
                        a.append(x)
            print(sum(a), end= " ")
if r==n :
            r = ((2^^(n))-1)
            print(r)
else:

            x= 2^^(r-1)
            a = [x]*n
            x= 1
            for _ in range(r-1):
                        a.pop(0)
                        a.append(x)
                        x= x*2


def lost(n,l,r):
    sum1=0
    sum2=0
    for i in range(r):
        sum2=sum2+(2**i)
    sum2=sum2+((n-r)*(2**(r-1))
    for j in range(l):
        sum1=sum1+(2**j)
    sum1=sum1+(n-l)
    return(str(sum1) +' '+ str(sum2))

a=input().split()
n=int(a[0])
l=int(a[1])
r=int(a[2])
print(lost(n,l,r))


import sys
import itertools

no = raw_input()
ans = raw_input()
l = len(no)
ans = ans[-l::1]

if int(ans[0])==0:
	print "WRONG_ANSWER"
	sys.exit()

smallest = no

permut in itertools.permutations(no, l):
	#print permut
	permut = "".join(list(permut))
	if permut[0]!="0" and permut<smallest:
		smallest = permut

if ans==smallest:
	print "OK"
else:
	print "WRONG_ANSWER"


if __name__ == '__main__':
	    n=raw_input()
		m=raw_input()
		l=len(n)
		n=list(n)
		n.sort()
		i=0
		while i<l and n[i]=='0':
			i+=1
		if i<l and i!=0:
			n[0]=n[i]
			n[i]='0'
		n=''.join(n)
		if n==m:
			print "OK"
		else:
			print "WRONG_ANSWER"