#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
void sieve() {
  vector<int> a(1000000, 0);
  for (int u = 2; u <= 1000000; u++) {
    if (a[u]) continue;
    for (int i = 2 * u; i <= 1000000; i += u) a[i] = u;
  }
  for (int i = 2; i <= 1000000; i++) {
    if (!a[i]) primes.push_back(i);
  }
}
int gcd(int a, int b) {
  while (1) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
int lcm(int a, int b) {
  int g = gcd(a, b);
  return ((a * b) / g);
}
int digitCount(int n) {
  int c = 0;
  while (n != 0) {
    c += n % 10;
    n /= 10;
  }
  return c;
}
int main() {
  int n;
  vector<int> ary = {0,   70,  140, 210,  280,  350,  601,  671, 741,
                     811, 881, 951, 1202, 1272, 1342, 1412, 1440};
  string str;
  cin >> str;
  n = (str[4] - 48) + (str[3] - 48) * 10 + (str[1] - 48) * 60 +
      (str[0] - 48) * 600;
  for (int i = 0; i < ary.size(); i++) {
    if (n <= ary[i]) {
      cout << ary[i] - n << endl;
      return 0;
    }
  }
}
