#include <bits/stdc++.h>
using namespace std;
const long long int imax = INT64_MAX;
const long long int imin = INT64_MIN;
vector<vector<pair<int, int>>> g;
template <class T>
T cal(T n) {
  return (n * 1ll * (n + 1));
}
template <class T>
T mx(T begin, T end) {
  return max_element(begin, end);
}
template <class T>
T mn(T begin, T end) {
  return min_element(begin, end);
}
template <class T>
void getUnique(vector<T>& nums) {
  sort(nums.begin(), nums.end());
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
}
template <class T>
void print(vector<T> nums) {
  for (T i : nums) cout << i << " ";
  cout << "\n";
}
template <class T>
void read(vector<T>& nums) {
  for (T& i : nums) cin >> i;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long t = 1;
  while (t--) {
    long long int a, b;
    char ch;
    cin >> a >> ch >> b;
    long long int ans = 0;
    string x, y;
    do {
      x = to_string(a);
      y = to_string(b);
      if (a / 10 == 0) {
        x = "0" + x;
      }
      if (b / 10 == 0) {
        y = "0" + y;
      }
      b++;
      a += b / 60;
      a %= 24;
      b = b % 60;
      ans++;
      reverse(y.begin(), y.end());
    } while (x != y);
    cout << ans - 1 << "\n";
  }
  return 0;
}
