#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int ans;
int w, m, n;
cin >> w >> m >> n;
if (w == 1)
{
cout << abs(m - n) << endl;
return 0;
}
int y = abs(m / w - n / w);
int x1 = m % w;
int x2 = n % w;
if (m % w == 0)
{
if (m > n)
{
y--;
}
else
{
y++;
}
x1 = w;
}
if (n % w == 0)
{
if (m < n)
{
y--;
}
else
{
y++;
}
x2 = w;
}
//cout << "y="<<y << " x1=" << x1 << " x2="<<x2 << endl;
if (((n / w) % 2 == 0 && (m / w) % 2 == 0 && m % w != 0 && n % w != 0)|| ((n / w) % 2 == 1 && (m / w) % 2 == 1) && m % w != 0 && n % w != 0)
{
//cout << " flag" << endl;
ans = y + abs(x1 - x2);
}
else
{
ans = y + abs((w - 1) - (x1 + x2 - 2));
}
cout << ans << endl;
return 0;
}
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
int get_length(int x)
{
int ans = 0;
while (x)
{
ans++;
x /= 10;
}
return ans;
}
bool pfs(int x)
{
for (int i = 1;i * i <= x;i++)
{
if (i * i == x)
{
return true;
}
}
return false;
}
int main()
{
int left, right;
cin >> left >> right;
for (int i = left;i <= right;i++)
{
int l = get_length(i);
int dadada = 1;
for (int j = 1;j < l;j++)
{
dadada *= 10;
}
for (int j = 1;j < l;j++)
{
int x1 = i % (dadada);
int x2 = (i - x1) / dadada;
if (pfs(i) && pfs(x1) && pfs(x2))
{
cout << i << endl;
break;
}
dadada /= 10;
}
}
return 0;
}
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int ans = n;
while (n >= 3)
{
ans += (n / 3);
n = (n / 3) + (n % 3);
}
cout << ans << endl;
return 0;
}
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
long long n;
long long ans = 0;
bool use[10];
int arr[10];
void f()
{
for (int i = 1;i <= 7;i++)
{
int flag1 = 1;
int num1 = 0;
while (flag1!=i+1)
{
num1 *= 10;
num1 += arr[flag1];
flag1++;
}
if (num1 >= n)break;
for (int j = i + 1;j <= 8;j++)
{
int flag2 = i+1;
int num2 = 0;
while (flag2 != j+1)
{
num2 *= 10;
num2 += arr[flag2];
flag2++;
}
int flag3 =j+1;
int num3 = 0;
while (flag3 != 10)
{
num3 *= 10;
num3 += arr[flag3];
flag3++;
}
long long d1 = n * num3;
long long d2 = 1ll*num1 * num3 + num2;
if (d1==d2)ans++;
//cout << "num1:" << num1 << "num2:" << num2 << "num3:" << num3 << endl;
}
}
}
void dfs(int u)
{
if (u > 9)
{
f();
return;
}
for (int i = 1;i <= 9;i++)
{
if (!use[i])
{
arr[u] = i;
use[i] = true;
dfs(u + 1);
use[i] = false;
}
}
}
int main()
{
cin >> n;
dfs(1);
cout << ans << endl;
return 0;
}