#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long MAX = 1e9 + 7;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 7;
int s[10];
char a[10];
void add(int x) {
  int res, ans = 0;
  s[3] += x;
  if (s[3] <= 9)
    return;
  else {
    res = s[3];
    s[3] = res % 10;
    s[2] = s[2] + res / 10;
    if (s[2] < 6)
      return;
    else {
      res = s[2];
      s[2] = res % 6;
      s[1] += res / 6;
      ans = s[0] * 10 + s[1];
      if (ans < 24) {
        s[1] = ans % 10;
        s[0] = ans / 10;
      } else {
        ans = ans % 24;
        s[1] = ans % 10;
        s[0] = ans / 10;
      }
      return;
    }
  }
}
int jude() {
  if (s[0] == s[3] && s[1] == s[2])
    return 1;
  else
    return 0;
}
int main() {
  cin >> a;
  s[0] = a[0] - '0';
  s[1] = a[1] - '0';
  s[2] = a[3] - '0';
  s[3] = a[4] - '0';
  long long sum = 0;
  for (int i = 0; i >= 0; i++) {
    add(i);
    if (jude()) {
      cout << sum << endl;
      return 0;
    }
    s[0] = a[0] - '0';
    s[1] = a[1] - '0';
    s[2] = a[3] - '0';
    s[3] = a[4] - '0';
    sum++;
  }
  return 0;
}
